16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UILabelを角丸にする&パディングを設定する方法

Posted at
角丸にする

LibraryにQuatzCore.frameworkを足す

# import <QuartzCore/QuartzCore.h>

- (void) hoge
{
    [[label layer] setCornerRadius:5.0];
    [label setClipsToBounds:YES];
}
パディングを設定する

参考
UILabelにパディング設定

サブクラスを作った方が良いそうです。

MyUILabel.m

- (void)drawTextInRect:(CGRect)rect
{
    // top, left, bottom, right
    UIEdgeInsets insets = {0, 20, 0, 20};

    return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}
16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?