`
zjjzmw1
  • 浏览: 1353955 次
  • 性别: Icon_minigender_1
  • 来自: 开封
社区版块
存档分类
最新评论

创建UILabel的子类使其能够让文字有上下左右的空隙

    博客分类:
  • iOS
阅读更多

 

@interface SubLabel : UILabel

 

@property (nonatomic, assign) UIEdgeInsets insets;

 

 

@end

 

- (id)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        self.insets = UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f);

    }

    returnself;

}

 

- (void)drawTextInRect:(CGRect)rect

{

    UIEdgeInsets insets = _insets;

    

    [superdrawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];

 

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics