【发布时间】:2020-06-06 14:56:35
【问题描述】:
我目前正在尝试将按钮制作成圆形,这是我的代码:
var raffleButton:UIButton = {
var button = UIButton()
button.translatesAutoresizingMaskIntoConstraints = false
button.titleLabel?.font = UIFont(name: "AvenirNext-Bold", size: 19)
button.setTitle("Tap To Enter Raffle!", for: .normal)
button.setTitleColor(UIColor.red, for: .normal)
button.backgroundColor = .white
button.layer.masksToBounds = true
button.frame = CGRect(x: 1600, y: 160, width: 160, height: 160)
button.layer.cornerRadius = button.frame.width/2
return button
}()
但是,当我运行代码时,按钮已损坏,看起来像以下...圆形和足球。
按钮看起来像它而不是一个圆圈有什么原因吗?
【问题讨论】:
标签: ios swift xcode uiview uibutton