I want to move a button to the center of the screen by code. I saw somewhere it is just few lines of code, but could not find them.
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- gactions CLI crashes on Windows when uploading goo
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- Windows - Android SDK manager not listing any plat
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
This should do it:
This centers the button in its superview:
Here is more simple approach:
Both rooster117 and DavidNg answers seem correct. Just to add one more "option" to you, if you want to do this animated, you should do:
There are some ways to do it without writing any code. If you you want to try to place the button into the centre of screen by using interface settings, you can view my clip.