【发布时间】:2021-01-24 08:43:52
【问题描述】:
按钮标题和图像未呈现。在iOS13及以下可以正常使用,但是更新到Xcode12.0.1和iOS14之后就不行了。
let viewAllButton: RoundedButton = {
let button = RoundedButton()
button.translatesAutoresizingMaskIntoConstraints = false
button.backgroundColor = .red
button.setTitle("View all", for: .normal)
button.setTitleColor(.white, for: .normal)
return button
}()
class RoundedButton: UIButton {
override func draw(_ rect: CGRect) {
super.draw(rect)
self.layer.cornerRadius = self.bounds.height / 2
self.layer.masksToBounds = true
}
}
【问题讨论】:
-
有人遇到同样的问题吗?
-
你能分享你的代码吗?
-
是的.......
-
请展示真实代码,包括 RoundedButton 是什么。见minimal reproducible example。
-
完成了!!...@matt
标签: ios swift uibutton uikit ios14