I have a button which I can locate easily with this code:
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)
)
)
But same code does not work for my UISegmentedControl. That goes x:0 y:0. What am I missing :/
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)
)
)
This one is worked, thanks to Philip Mills
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))