IOS 视图缓慢推出效果实例

来源:互联网 发布:阿里云code容量 编辑:程序博客网 时间:2024/06/03 17:38

作者:朱克锋

邮箱:zhukefeng@iboxpay.com

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

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

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


#define MARGIN_LEFT    12.0f

#define MARGIN_CELL_TOP48.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.contentViewaddSubview:contentView];

    [cell.contentViewaddSubview: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);

                         }];


}

原创粉丝点击