作者:朱克锋
邮箱:zhukefeng@iboxpay.com
转载请注明出处:http://blog.youkuaiyun.com/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);
}];
}