根据文字内容确定控件尺寸
2016-01-07 15:46
344 查看
// 自适应字体宽度
- (CGSize)customSizeWithFont:(UIFont *)font
{
CGSize size = [selfsizeWithAttributes:@{NSFontAttributeName:font}];
return size;
}
// 根据内容计算 Label 高度
- (CGFloat)adjustHeightWithContent:(NSString *)content
{
CGRect contentBounds = [content
boundingRectWithSize:CGSizeMake(kScreenWidth -
kEdgeInRegisterTreaty *
2,1000)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary
dictionaryWithObject:
[RMUtils
defaultFont]
forKey:NSFontAttributeName]
context:nil];
return contentBounds.size.height +
5;
}
- (CGSize)customSizeWithFont:(UIFont *)font
{
CGSize size = [selfsizeWithAttributes:@{NSFontAttributeName:font}];
return size;
}
// 根据内容计算 Label 高度
- (CGFloat)adjustHeightWithContent:(NSString *)content
{
CGRect contentBounds = [content
boundingRectWithSize:CGSizeMake(kScreenWidth -
kEdgeInRegisterTreaty *
2,1000)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary
dictionaryWithObject:
[RMUtils
defaultFont]
forKey:NSFontAttributeName]
context:nil];
return contentBounds.size.height +
5;
}
相关文章推荐
- Javascript模块化编程(三):require.js的用法
- NetCore NW714 v2.0路由器TTL救砖
- linux 常用命令总结
- Apache配置压缩优化时报错——undefined symbol: inflateEnd
- .NET MVC Iframe 'X-Frame-Options' to 'SAMEORIGIN' 解决办法
- 重载与重写
- 使用gson在解析unicode时遇到的问题
- WebView加载网页完成后跳转到about:blank
- 换成atomikos后报java.lang.AbstractMethodError: oracle.jdbc.driver.LogicalConnection.createClob()Ljava/sq
- 在Oracle中查看表空间的使用情况
- 2016/1/7文件上传下载代码
- C# 两个独立exe程序直接通信
- Bugfree安装步骤[转载]
- html5 iphone 特殊meta属性学习
- Javascript模块化编程(二):AMD规范
- Java基础之基本类型转换知识点详解
- nagios插件ndoutile
- Apache Thrift之java入门例子
- FTL中常用说明
- noetpad++ 使用svn