如何在iOS中删除UILabel中的insets

时间:2016-05-31 14:55:25

标签: ios iphone user-interface autolayout

我有简单的标签,文字D,我使用sizeToFit,我的身高是21.5

但我看到填充大约2px

如何删除它?

enter image description here enter image description here

我尝试layoutMargins = UIEdgeInsetsZero - 但没有效果

2 个答案:

答案 0 :(得分:0)

您可能想尝试将UILabel子类化并覆盖drawTextInRect:

- (void)drawTextInRect:(CGRect)rect
{
    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(0., 0., 0., 0.))];
}

答案 1 :(得分:0)

estTotal