我有一个可以使用此代码轻松找到的按钮:
let btnRewind = UIButton(
frame:CGRect(
x:(UIScreen.main.bounds.size.height/2 - 4*UIScreen.main.bounds.size.height/30),
y:(UIScreen.main.bounds.size.width/2 - UIScreen.main.bounds.size.height/30),
width:(UIScreen.main.bounds.size.height/15),
height:(UIScreen.main.bounds.size.height/15)
)
)
但是同样的代码对我的UISegmentedControl不起作用。这是x:0 y:0。我错过了什么:/
var sgmSpeed = UISegmentedControl(
frame:CGRect(
x:(UIScreen.main.bounds.size.height/2 - UIScreen.main.bounds.size.height/30),
y:(UIScreen.main.bounds.size.width/2 - UIScreen.main.bounds.size.height/30),
width:(UIScreen.main.bounds.size.height/15),
height:(UIScreen.main.bounds.size.width/15)
)
)
答案 0 :(得分:0)
感谢菲利普米尔斯,这个是有效的
sgmSpeed.frame = CGRect.init(x:(UIScreen.main.bounds.size.height/2 - UIScreen.main.bounds.size.height/6),
y:(UIScreen.main.bounds.size.width/2 + UIScreen.main.bounds.size.height/15),
width:(UIScreen.main.bounds.size.height/3),
height:(UIScreen.main.bounds.size.width/15))