Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS cutting off UILabel/UIButton with some fonts

Tags:

ios

swift

I have custom fonts in my project. But i detected some of the fonts that comes also with XCode have the same problem. For unknown reason the if i set accents to a capital letter (which is very common in Spain, like Álgreba) the top of the text is cutting of.

enter image description here

For other fonts is more clear since i can't even see half accent. I can do a trick which is with UILabel setting a height constraint, but this trick doesn't apply to UIButton or to the title of the navigationBar. I tried also in UILabel calling sizeToFiT with no succeed.

like image 955
Godfather Avatar asked Sep 16 '15 11:09

Godfather


1 Answers

i had same problem using a button with an image and custom font. this worked out

btn.contentVerticalAlignment = .fill
btn.contentMode = .center
btn.imageView?.contentMode = .scaleAspectFit
like image 145
mate0 Avatar answered Oct 22 '22 00:10

mate0