我按钮的titleLabel变为"...".在iOS10上
问题描述:
当我使用iOS 10时,某些按钮标签的文本变为"...".我在iOS9中发现相同的字符串(e.x:我是人)使用48宽度.在iOS10中,它使用48.96宽度.如何解决?
When I use iOS 10 some button label's text become "...". I found the same string (e.x:我是人) in iOS9 uses 48 width. In iOS10 it uses 48.96 width. How to fix?
答
您必须使用按钮titleLabel的"adjustsFontSizeToFitWidth"属性
You have to use "adjustsFontSizeToFitWidth" property of titleLabel of your button
示例:
myButton.titleLabel.adjustsFontSizeToFitWidth = YES;
此行将根据按钮的宽度自动调整myButton文本的字体大小.
This line will automatically adjust font size for the text of myButton based on the width of the button.
使用此链接:将UIButton字体大小调整为宽度
另一种解决方案是通过调整约束来增加按钮的宽度.
Another solution is to increase the width of the button, by adjusting constraints.