ios - 如何使 UIButton 文本动态化?

标签 ios swift uibutton storyboard

所以我在堆栈 View 中有一个 UIButton 。到目前为止,按钮是动态的并相应缩小尺寸。问题是里面的文本不会根据屏幕尺寸而变小。我正在使用 Storyboard 和 Swift。

The way the button looks on iPhone5

最佳答案

获取按钮的 titleLabel 并将 setAdjustsFontSizeToFitWidth 设置为 YES

这是 objC 方式

[[button titleLabel] setAdjustsFontSizeToFitWidth:YES];

关于ios - 如何使 UIButton 文本动态化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34349385/

相关文章:

ios - 第一次点击 UITextField.inputView = UIPickerView 时显示键盘

swift - 尝试创建拖放到 TableView 。 swift

ios - 在不禁用 subview 的情况下禁用 UITextField 的编辑

iOS:拆分键 - 由 NSString 中的等号连接的值

ios - UIScrollViewDelegate 函数未调用

ios - iOS 8 中的 layoutMarginsFollowReadableWidth 错误

iphone - 将按钮添加到 UITableViewCell

ios - 带有按钮点击检测的 NSInvalidArgumentException

ios - 嵌套 UINavigationController 内 View 的方向不正确

ios - 如何在 iOS 和 FB SDK 3.7 上处理过期的 Facebook 访问 token