UILabel高度计算 [英] UILabel height calculation

查看:99
本文介绍了UILabel高度计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有UILabel,该文本是根据服务器数据动态更改的.有时数据太长​​,使我的UILabel变成多行.有什么方法可以计算我的UILabel的高度?

I have UILabel that the text is dynamically change based on server data. Sometime the data is so long that make my UILabel become multiline. Is there any way to calculate the height of my UILabel?

推荐答案

您可以使用此:

var labelHeight : CGFloat
labelHeight = theLabel.boundingHeightForFixedWidth(theLabel.bounds.width)

希望对您有所帮助:)

这篇关于UILabel高度计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆