ios - 如何在 iOS 中添加相对于其他 UI 元素的 UILabel

标签 ios layout uiview uilabel custom-controls

如何添加相对于其他 UI 元素(以及自定义 View /控件)的标签?

最佳答案

您应该对框架属性进行操作(例如,将标签放在按钮底部):

CGRect buttonRect = self.myButton.frame;
buttonRect.origin.y = buttonRect.origin.y + buttonRect.size.height;
UILabel *lbl = createALabel();
lbl.frame = buttonRect;
[self.myButton.superview addSubView:lbl];

关于ios - 如何在 iOS 中添加相对于其他 UI 元素的 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5116502/

相关文章:

ios - 从屏幕右侧向左滑动 UIView

ios - Realm swift : how to catch RLMException?

iphone - 使用 Custom Segue 以编程方式导航到另一个 ViewController

ios - 错误,核心数据,原因: '*** -[_PFArray objectAtIndex:]: index (2) beyond bounds (2)'

android - 单击任何 EditText 时屏幕向上滚动

java - 为什么 JTable 没有显示?

ios - UIView animateWithDuration 使应用程序在从 dispatch_async block 调用时挂起

ios - 在 iOS 11 上将 insetsContentViewsToSafeArea 设置为 false 的 iPhone X 上,UITableView 单元格不会从屏幕的边缘延伸到屏幕的边缘

android - 如何设法在自定义 View 组中将一个 child 带到其他 child 的前面?

ios - UIView 和 UIButton 上的 UIView 不起作用