2
A
回答
3
你的问题不是很清楚,但可以如下得到关于屏幕尺寸信息:
// Screen Sizes
let screenWidth = UIScreen.mainScreen().bounds.width
let screenHeight = UIScreen.mainScreen().bounds.height
然后,您可以修改框架或按钮这样的中心位置:
// Change frame
btnName.frame = CGRectMake(screenWidth/3, screenHeight/2, 100, 100)
// Change center of button
btnName.center = CGPoint(x: screenHeight/2, y: screenWidth/2)
希望它有帮助
+0
in viewDidLoad this not工作!我应该在哪里写这段代码? –
+0
如果您向我提供一些您的代码,我相信我可以更有帮助... – TurtleFan
相关问题
- 1. 以编程方式移动UIButton?
- 2. 如何以编程方式移动UIButton。 Objective C xCode
- 3. 以编程方式移除uiview by uibutton
- 4. 以编程方式编码UIButton行动
- 5. 如何以编程方式创建UIButton
- 6. UIButton UIPopUpController以编程方式
- 7. 以编程方式定义UIButton快速
- 8. 以编程方式获取UIButton
- 9. 以编程方式禁用UIButton
- 10. 以编程方式中心UIButton
- 11. 从IBAction以编程方式添加UIButton
- 12. 以编程方式向UINavigationController添加UIButton
- 13. 以编程方式禁用UIButton
- 14. 以编程方式更改UIButton状态
- 15. 以编程方式更改UIButton标题
- 16. 如何以编程方式连接UIButton和方法?
- 17. Magento - 以编程方式移动类别
- 18. 以编程方式移动UIImageView框架
- 19. EXTSJS:treepanel以编程方式移动分支
- 20. 以编程方式移动FormulaFieldDefinition对象
- 21. 以编程方式移动AutoscrollBar
- 22. 以编程方式移动鼠标
- 23. 如何以绝对布局以编程方式移动按钮
- 24. 如何以编程方式启动移动中心(MBLCTR.EXE)
- 25. Swift以动态高度以编程方式创建UIButton
- 26. UIButton IB vs编程方式
- 27. 如何以编程方式向UIButton提供光面外观?
- 28. 如何以编程方式将UIButton添加到UIToolBar?
- 29. 如何在Swift中以编程方式更改UIButton状态
- 30. 如何以编程方式快速添加自定义UIButton
button.center = newPosition; ? –
您可以通过更改框架 –
或buttonTopConstraint.constant = newVerticalValue; [[button superView] setNeedsLayout]; –