Ant*_*ony 5 iphone objective-c rubymotion
我有一个类型为UIButtonRoundedRectType的UIButton,我希望水平和垂直放置在屏幕中间.
我已经尝试通过硬编码来做到这一点,但这在iPhone和iphone(视网膜)上运行时回顾过去.我想通过计算容器的宽度以编程方式将按钮保持在中心位置.
所以,我试过这个,但它不起作用.
container = view.frame.size
button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
button.frame = [[container.width/2-button.frame.size.width/2,150], [280,50]]
Run Code Online (Sandbox Code Playgroud)
怎么样:
button.center = [button.superview convertPoint:button.superview.center fromView:button.superview.superview];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8080 次 |
| 最近记录: |