Ana*_*log 14 xcode interface-builder uibutton ios
UILabel Dynamic Type: Automatically Adjusts Font在Interface Builder的Attributes Inspector中有一个复选框.
Interface Builder中是否有等效的自动调整UIButton的字体大小,还是必须在代码中处理?
我正在使用Xcode 9.0 beta 6,目标是iOS 11.
bom*_*mpf 13
显然没有,但解决起来并不是很难.您可以UIButton使用@IBInspectable属性进行扩展:
extension UIButton {
@IBInspectable
var adjustsFontForContentSizeCategory: Bool {
set {
self.titleLabel?.adjustsFontForContentSizeCategory = newValue
}
get {
return self.titleLabel?.adjustsFontForContentSizeCategory ?? false
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,您只需为每个UIButton(或其任何子类)打开它.
| 归档时间: |
|
| 查看次数: |
1853 次 |
| 最近记录: |