开发者

Dynamic height of my OHAttributedLabel

开发者 https://www.devze.com 2023-03-22 21:40 出处:网络
I am using the Custom UILabel class OHAttributedLabel to display my text as JUSTFIED. After my OHAttributedLabel i want to displaya UIButtton . How to get the Dynamic height of my OHAttributedLabel .

I am using the Custom UILabel class OHAttributedLabel to display my text as JUSTFIED . After my OHAttributedLabel i want to display a UIButtton . How to get the Dynamic height of my OHAttributedLabel . I tried many ways that found in stackoverflow itself. Unfortunately none 开发者_StackOverflow中文版of the methods are giving me the correct Height . Help me to fox this issue ......


Hi I am the author of OHAttributedLabel. Thanks for using it.

Did you try to use sizeToFit an sizeThatFits: methods? sizeThatFits: is a UIView method (that I override in OHAttributedLabel) that gives you the ideal size of the view/label depending on it's content.

You can also use my NSAttributedString+Attributes addition to compute the size of you NSAttributedString in pixels (I recently added a method in the header for that, and actually sizeThatFits call it)

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消