ios - 如何对齐 UILabel 框架底部的 UILabel 内的文本?

标签 ios swift xcode

标签内的文本水平和垂直居中对齐。如何将文本设置为在中间水平轴下方对齐?

最佳答案

您可以通过子类化 UILabel 并覆盖此方法来做到这一点

- (void)drawTextInRect:(CGRect)rect {
  UIEdgeInsets insets = {6, 5, 0, 5};//{top, left,bottom,right} Change the padding values as your need
 [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}

关于ios - 如何对齐 UILabel 框架底部的 UILabel 内的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56748259/

相关文章:

ios - 如何在 Xcode Storyboard中设置正确的 UIImageView?

ios - 选择行时更改 UIImageView 颜色,如 UILabel 的突出显示属性?

ios - 如何让 MKPolylines 在 MKMapView (iOS) 中正确地跟随道路?

ios - 用于在 iPhone 设备上显示持久存储内容的 GUI

ios - 以半尺寸显示模态视图 Controller

swift - 从 HTTP 请求中获取值并刷新 UIView 标签值

ios - 使用 TabBarViewController 呈现 NavigationController 无法以编程方式选择索引

ios - Xcode 4.5 中的当前位置错误

ios - 连接到 iBeacon

ios - 哪里可以下载twitterkit框架