在协议方法里面写动画
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.alpha = 0.5;
CGAffineTransform transformScale = CGAffineTransformMakeScale(0.3,0.8);
CGAffineTransform transformTranslate = CGAffineTransformMakeTranslation(0.5, 0.6);
cell.transform = CGAffineTransformConcat(transformScale, transformTranslate);
[tableView bringSubviewToFront:cell];
[UIView animateWithDuration:.4f
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
cell.alpha = 1;
//清空 transform
cell.transform = CGAffineTransformIdentity;
} completion:nil];
}
//-----------------------------
//根据 字符串的长度、字体大小、以及宽度 返回CGRect
+(CGRect)rectHeightWithStr:(NSString *)str AndFont:(CGFloat)fontFloat WithStrWidth:(CGFloat)width;
//根据 字符串的长度、字体大小、已经高度 返回CGRect
+(CGRect)rectWidthWithStr:(NSString *)str AndFont:(CGFloat)fontFloat WithStrHeight:(CGFloat)height;
//----------实现-------------------
//根据 字符串的长度、字体大小、以及宽度 返回CGRect
+(CGRect)rectHeightWithStr:(NSString *)str AndFont:(CGFloat)fontFloat WithStrWidth:(CGFloat)width
{
CGRect fcRect = [str boundingRectWithSize:CGSizeMake(width, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontFloat]} context:nil];
return fcRect;
}
//根据 字符串的长度、字体大小、已经高度 返回CGRect
+(CGRect)rectWidthWithStr:(NSString *)str AndFont:(CGFloat)fontFloat WithStrHeight:(CGFloat)height
{
CGRect fcRect = [str boundingRectWithSize:CGSizeMake(1000, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontFloat]} context:nil];
return fcRect;
}