Cell自适应高度
来源:互联网 发布:sql union 不同字段 编辑:程序博客网 时间:2024/05/22 14:25
CGSize size = CGSizeMake(300, 1000);
// 2.NSStringDrawingUsesLineFragmentOrigin 按行计算内容高度
// 3.创建存放字体的字典,字体大小要与contentlabel字体大小一致
NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName];// key处固定
CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
+(CGFloat)heightForContent:(NSString *)text
{
// 1.设置内容最大显示高度 其中宽度是跟contentLabel宽度一样
CGSize size = CGSizeMake(300, 1000);
// 2.NSStringDrawingUsesLineFragmentOrigin 按行计算内容高度
// 3.创建存放字体的字典,字体大小要与contentlabel字体大小一致
NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName];// key处固定
CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
return frame.size.height;
}
图片
[super layoutSubviews];
CGFloat picHeight = self.MyViewImage.image.size.height * self.contentView.frame.size.width / self.MyViewImage.image.size.width;
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14],NSFontAttributeName, nil];
CGRect rect = [self.MyLabel.text boundingRectWithSize:CGSizeMake(375, 400) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
self.MyViewImage.frame = CGRectMake(0, 0, self.contentView.frame.size.width, picHeight);
self.MyLabel.frame = CGRectMake(0, picHeight, self.contentView.frame.size.width, rect.size.height);
- UItableView cell 自适应高度
- iOS Cell高度自适应
- ios cell自适应高度
- iOS8 Cell 高度自适应
- Cell自适应高度
- cell单元格高度自适应
- cell自适应高度
- cell自适应高度
- cell的自适应高度
- cell自适应高度
- Cell自适应高度
- cell高度自适应
- cell高度自适应
- cell自适应高度
- cell自适应高度
- cell自适应高度
- masonry + 自适应cell高度
- cell自适应高度
- windows8.1下U盘方式安装Ubantu15.04
- iOS - 创建表格类视图WBDataGridView
- 赢在习惯——高效能人士的七个成功法则
- redis -- 分帀式cache
- Jquery Datepicker控件赋值
- Cell自适应高度
- WIN7护眼颜色设置
- Android TextView的setText()与Integer之间一个易犯的小错误
- 大数据技术-HBase:MSLAB介绍
- Android电容屏一些重要说明
- 字符串匹配的KMP算法
- 最大流算法 Dinic HDU 1532
- Java多线程系列--“基础篇”03之 Thread中start()和run()的区别
- UITabbar系统默认蓝色修改