1
我有文字d簡單的標籤和我使用sizeToFit我得到了高度21.5如何刪除插圖中的UILabel iOS中
不過我看填充約2px的
如何去除呢?
我嘗試layoutMargins = UIEdgeInsetsZero - 但沒有效果
我有文字d簡單的標籤和我使用sizeToFit我得到了高度21.5如何刪除插圖中的UILabel iOS中
不過我看填充約2px的
如何去除呢?
我嘗試layoutMargins = UIEdgeInsetsZero - 但沒有效果
你可能想嘗試繼承了UILabel
和壓倒一切的drawTextInRect:
有:
- (void)drawTextInRect:(CGRect)rect
{
[super drawTextInRect:UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(0., 0., 0., 0.))];
}
CGRect frame = CGRectMake(0, 0, 120, 30);
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0, 0, 0, 0);
CGRect labelFrame = UIEdgeInsetsInsetRect(frame, contentInsets);
UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
嘗試設置文本DJ,看看魔術是否發生在底部? –
沒有變化。只有底部刪除 –
這是因爲字體的高度。我刪除了底部填充,這意味着可能會有一些字符比D更高,這將會達到拉貝的頂部 –