iOS SDK : Moving the button into the center of screen by code

标签 ios button sdk position

我想通过代码将一个按钮移动到屏幕中央。我在某处看到它只有几行代码,但找不到它们。

最佳答案

这使按钮在其父 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/

相关文章:

paypal - 我可以将 Braintree SDK(特别是我需要 Apple Pay)与 PayPal Gateway 一起使用吗?

ios - 从我的数组中检索字符串时出错

使用路径作为附加属性的 WPF 自定义形状按钮模板

html - 如何在突出显示按钮时更改按钮内的文本?

c# - Microsoft Kinect SDK 1.6 缺少 KinectSensorChooser 组件?

iphone - 从 ASIHTTPRequest 转换为 AFNetworking

ios - 如何显示hh :mm:ss in NSTimer?

ios - WKWebView 在 StoryBoard 中还是以编程方式(Swift 4)?

iphone - 在 iOS 上,为什么 shouldAutorotateToInterfaceOrientation 被调用 10、12 或 13 次?

JAVAFX 如何使堆叠在标签后面的按钮可点击