ios - iOS 13 将圆形按钮更改为对角线
问题描述
我在视图控制器中有以下两个按钮,它们在 iOS 12 和 XCode 11 中显示我需要的圆形按钮,但是当我使用 iOS 13 和 XCode 11 时,它们是对角线的,如图所示。
self.saveBtn.frame.size = CGSize(width:70,height:70)
self.saveBtn.layer.cornerRadius = self.saveBtn.frame.size.height/2.0
self.saveBtn.layer.borderColor = UIColor.lightGray.cgColor
self.saveBtn.layer.borderWidth = 1.5
self.saveBtn.clipsToBounds = true
self.saveBtn.titleLabel?.font = UIFont(name:"HelveticaNeue", size:18)
self.saveBtn.titleLabel?.adjustsFontSizeToFitWidth = true
self.cancelBtn.frame.size = CGSize(width:70,height:70)
self.cancelBtn.layer.cornerRadius = self.cancelBtn.frame.size.height/2.0
self.cancelBtn.layer.borderColor = UIColor.lightGray.cgColor
self.cancelBtn.layer.borderWidth = 1.5
self.cancelBtn.clipsToBounds = true
self.cancelBtn.titleLabel?.font = UIFont(name:"HelveticaNeue", size:18)
self.cancelBtn.titleLabel?.adjustsFontSizeToFitWidth = true
如何将这些按钮转换回圆形?
解决方案
我不确定,但试试这个
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.saveBtn.frame.size = CGSize(width:70,height:70)
self.saveBtn.layer.cornerRadius = self.saveBtn.frame.size.height/2.0
self.saveBtn.layer.borderColor = UIColor.lightGray.cgColor
self.saveBtn.layer.borderWidth = 1.5
self.saveBtn.clipsToBounds = true
self.saveBtn.titleLabel?.font = UIFont(name:"HelveticaNeue", size:18)
self.saveBtn.titleLabel?.adjustsFontSizeToFitWidth = true
self.cancelBtn.frame.size = CGSize(width:70,height:70)
self.cancelBtn.layer.cornerRadius = self.cancelBtn.frame.size.height/2.0
self.cancelBtn.layer.borderColor = UIColor.lightGray.cgColor
self.cancelBtn.layer.borderWidth = 1.5
self.cancelBtn.clipsToBounds = true
self.cancelBtn.titleLabel?.font = UIFont(name:"HelveticaNeue", size:18)
self.cancelBtn.titleLabel?.adjustsFontSizeToFitWidth = true
}
}
推荐阅读
- css - 在 safari 浏览器中单击时,bootstrap vue(b-tabs)显示蓝色轮廓
- angular - *ngif 模板中的 typescript null 错误
- jquery - 引导轮播仅适用于 jquery slim
- android - 无法从后端服务器获取 jwt
- python - 带有硒的机器人,我无法弄清楚这个错误
- exception - Erlang中的function_clause和badarg有什么区别?
- python - 用于遍历 mysql 表和更改表空间的 Python 脚本
- python - 如何修复“TypeError:列表索引必须是整数或切片,而不是元组”
- android - 应用程序在发布时崩溃,但在调试模式下工作正常
- python - 在 TF 中,自动命名为 Conv2DBackpropInput 的张量代表什么?