自定义cell高度和获取图片高度宽度
1---------获取图片的高度宽度
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url];
UIImage*showimage = [UIImageimageWithData:data];
CGFloat width = showImage.size.width;(宽度)
CGFloat height = showImage.size.height;(高度);
2.----------------自定义cell高度- 文字自适应
+ (CGFloat)getStringHeight:(NSString*)string font:(CGFloat)fontSize { CGRect rect = [string boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-40, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil]; return ceil(rect.size.height);}
网友评论