我需要通过编程方式设置UIButton标题UILabel的字体大小。
当前回答
button.titleLabel.font = <whatever font you want>
对于那些想知道为什么他们的短信不显示的人,如果你这样做了
button.titleLabel.text = @"something";
它不会显示,你需要做:
[button setTitle:@"My title" forState:UIControlStateNormal]; //or whatever you want the control state to be
其他回答
希望对你有所帮助
[_button.titleLabel setFont:[UIFont systemFontOfSize:15]];
祝你好运
快4.倍
button.titleLabel?.font = UIFont.systemFont(ofSize: 20)
【按钮setFont:……已被弃用。
使用[按钮。titleLabel setFont:…而是,例如:
[myButton.titleLabel setFont:[UIFont systemFontOfSize:10]];
这应该能让你振作起来
[btn_submit.titleLabel setFont:[UIFont systemFontOfSize:14.0f]];
objective - c:
[button.titleLabel setFont: [button.titleLabel.font fontWithSize: sizeYouWant]];
迅速:
button.titleLabel?.font = button.titleLabel?.font.fontWithSize(sizeYouWant)
只会改变字体大小。
推荐文章
- 如何在iOS中使用Swift编程segue
- Swift -整数转换为小时/分钟/秒
- Swift:声明一个空字典
- 为什么ARC仍然需要@autoreleasepool ?
- 在成功提交我的应用程序后,“太多符号文件”
- 首先添加一个UIView,甚至是导航栏
- 我如何改变UIButton标题颜色?
- 如何从UIImage (Cocoa Touch)或CGImage (Core Graphics)获取像素数据?
- 在Swift中如何调用GCD主线程上的参数方法?
- NSLayoutConstraints是可动画的吗?
- iOS -构建失败,CocoaPods无法找到头文件
- Xcode 4挂在“附加到(应用程序名称)”
- CFNetwork SSLHandshake iOS 9失败
- 请求失败:不可接受的内容类型:文本/html使用AFNetworking 2.0
- 缺少推荐的图标文件-该包不包含iPhone / iPod Touch的应用程序图标,像素为“120x120”,png格式