【iOS】swift-文字宽度的计算
来源:互联网 发布:网络福禄克怎么测试 编辑:程序博客网 时间:2024/05/17 07:28
如图所示,需要sectionView的标题宽度可以动态变化
举例说明:
只需在tableView的代理方法
func tableView(tableView:UITableView, viewForHeaderInSection section:Int) -> UIView? {
let view = tableView.dequeueReusableHeaderFooterViewWithIdentifier(sectionViewId)as! NameListSectionView
view.updateLabel(“xxxxxxxxxx”)
return view
}
然后在sectionView文件里
func updateLabel(labelText:String){
label.text = labelText
let statusLabelSize = labelText.sizeWithAttributes([NSFontAttributeName : UIFont.systemFontOfSize(13)])
labelWidthConstraint.constant = statusLabelSize.width + 4
layoutIfNeeded()
}
labelWidthConstraint为Xib文件里 label宽度的约束,右边横线的左边设置为到label右端的间隔即可
0 0
- 【iOS】swift-文字宽度的计算
- iOS 动态计算文字高度和宽度
- iOS 编程 计算字符串文字宽度
- iOS开发之计算文字宽度
- swift中根据宽度计算文字高度的方法的封装
- Swift中关于计算文本的宽度
- 计算文字的宽度和高度
- 计算文字的宽度(动态)
- 动态计算_shortLabel的文字宽度
- 计算文字的高度和宽度
- 计算textview 文字宽度
- 【iOS 开发】Xcode6中计算文字的宽度或高度 ——伊禾媛
- iOS自定义控件中动态计算文字控件的高度宽度
- iOS-UILabel的宽度自适应文字
- iOS-UILabel的宽度自适应文字
- Swift-- 计算文字尺寸
- iOS 计算文字的高度
- ios计算文字的大小
- Android弹出Dialog使背景变暗的实现方式
- React-native简单button实现
- 《Unix高级环境编程》第七章 进程环境
- 微信组件:微信转账查询
- linux挂载windows共享目录
- 【iOS】swift-文字宽度的计算
- Android Tool——Hierachy Viewer可视化调试
- 缓存的误区(上)
- Apache安装问题:configure: error: APR not found . Please read the documentation
- Golang(Go语言)中append函数返回值必须有变量接收的原因探究
- java 设计模式之迪米特法则
- 侧滑菜单
- Qt动态库调试方法2
- JavaScript小技巧