简体   繁体   中英

UILabel with Shadow changes Shadow Offset when Autoshrinking

I have a UILabel with a white shadow offset at 1 vertical pixel and it looks fine at its normal size: http://cl.ly/PBtC

But if the text inside the label gets large enough for Autoshrink to scale it down the shadow offset grows much more than a pixel. See here: http://cl.ly/PC4M

And the offset amount seems to change based on how much the UILabel is Autoshrunk: http://cl.ly/PBtn

Has anyone seen this? There is nothing funny about my UILabel and it is very repeatable. Here are my IB settings: http://cl.ly/PCIx

Any ideas on a fix?

I've encountered the same issue (supposedly an IB bug). As of now (Xcode 4.6.2), it seems that one can have either Minimum Font Scale or Tighten Letter Spacing enabled . Minimum Font Size seems to work fine with Tighten Letter Spacing .

Also take a look at UILabel min font size shadow issue .

Without seeing your code, my best guess is that UILabel is not handling the autoresize properly with respect to the shadow. I would recommend creating a UILabel subclass, and handling the shadow manually by overriding layoutSubviews . If you can confirm that it is a UIKit bug, file a report with Apple.

I reproduced the same exact result using your IB settings.

For a fix, change the text type to attributed text and everything works fine as is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM