【发布时间】:2020-11-04 03:21:01
【问题描述】:
我有一个 UIButton 的简单代码:
let myButton = UIButton()
myButton.setImage(#imageLiteral(resourceName: "cross"), for: .normal)
myButton.tintColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
view.addSubview(myButton)
我想将按钮设置为位于屏幕左上方。我尝试使用 CGRect 框架,但这并没有达到我想要的效果。我试图弄清楚如何将按钮的左侧放在安全区域,将按钮的顶部放在安全区域,尽管我不知道该怎么做。 (我对编码有点陌生,并且一直在使用故事板......)
【问题讨论】:
标签: swift uibutton constraints nslayoutconstraint