I have a UIButton of type UIButtonRoundedRectType, which I want to place horizontally and vertically in the middle of the screen.
I tried to do this by the hard drive numbers, but it looks back when working on an iPhone against an iphone (retina). I would like to programmatically hold the button in the center while calculating the width of the container.
So, I tried this, but it does not work.
container = view.frame.size
button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
button.frame = [[container.width/2-button.frame.size.width/2,150], [280,50]]
source
share