开发者

Use SizeToFit() on a UILabel with a shadow?

开发者 https://www.devze.com 2023-02-05 18:44 出处:网络
I am having some UILabel elements for which a dynamically alter the text. I also add shadows to the labels using label.Layer.ShadowOffset and dito color.

I am having some UILabel elements for which a dynamically alter the text. I also add shadows to the labels using label.Layer.ShadowOffset and dito color.

When the text of a label has been changed I use SizeToFit. Problem: That method do开发者_开发技巧es not take into account the shadows - which leads to labels that are too small and the shadows are cut of.

Is there an easy way to fix this, or do I have to manually alter the size after the SizeToFit call?


Why are you setting the shadow on the layer, instead of using UILabel's shadowOffset and shadowColor properties? I would expect sizeToFit to account for the shadow in that case.

0

精彩评论

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