繁体   English   中英

如何在UILabel框架底部的UILabel中对齐文本?

[英]How to align the text inside UILabel at the bottom of UILabel frame?

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

您可以通过子类化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)];
}

有很多方法可以做到这一点。 但这是最简单的。

创建一个UIView

将该标签添加到该视图中

添加自动布局约束以从视图底部定义固定边距。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM