我想通过代码将一个按钮移动到屏幕中央。我在某处看到它只有几行代码,但找不到它们。
最佳答案
这使按钮在其父 View 中居中:
CGRect bounds = button.superview.bounds;
button.center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
关于iOS SDK : Moving the button into the center of screen by code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11527824/