IOS 视图缓慢推出效果实例

作者:朱克锋

邮箱:zhukefeng@iboxpay.com

转载请注明出处:http://blog.csdn.net/linux_zkf

我们经常看到应用中点击一个表CELL时,下面会慢慢推出一个文本,用于显示相关的说明,再次点击时会慢慢缩回

,这里实现的是慢慢推出的效果


#define MARGIN_LEFT     12.0f

#define MARGIN_CELL_TOP 48.0f

#define VIEW_WIDTH      296.0f

#define VALUE_NONE              0.0f

- (void) show:(UITableViewCell *)cell withTitle:(NSString *) content

{

    UIView *contentView = nil;

    UITextView * contentTextView =nil;

    contentView = [[[UIViewalloc] initWithFrame:CGRectMake(MARGIN_LEFT,MARGIN_CELL_TOP, VIEW_WIDTH,VALUE_NONE)]autorelease];

    contentTextView = [[[UITextViewalloc]initWithFrame:CGRectMake(MARGIN_LEFT,MARGIN_CELL_TOP,VIEW_WIDTH,VALUE_NONE)]autorelease];

    contentTextView.text = content;

    contentTextView.layer.borderWidth =0.5f;

    contentTextView.layer.cornerRadius =10.0f;

    contentTextView.font = [UIFontsystemFontOfSize:FONT_SIZE];

    contentTextView.userInteractionEnabled =YES;

    contentTextView.editable =NO;


    //这里要把view添加到父视图中

    [cell.contentView addSubview:contentView];

    [cell.contentView addSubview:contentTextView]; 

    //这里height为你想最终扩大的高度

   [UIViewanimateWithDuration:0.2

                         animations:^ {

                             contentView.frame =CGRectMake(MARGIN_LEFT, MARGIN_CELL_TOP, VIEW_WIDTH, height);

                             contentTextView.frame =CGRectMake(MARGIN_LEFT, MARGIN_CELL_TOP, VIEW_WIDTH, height);

                         }];


}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值