设置UILabel的内间距

由于UILabel没有相关属性设置内间距,只能本身从新自定义atom

//1.header fileit

    #importio

    @interface InsetsLabel : UILabelimport

    @property(nonatomic) UIEdgeInsets insets;file

    -(id) initWithFrame.:(CGRect)frame. andInsets: (UIEdgeInsets) insets;im

    -(id) initWithInsets: (UIEdgeInsets) insets;co

    @endheader

    //2. implementation filereturn

    @implementation InsetsLabelinterface

    @synthesize insets=_insets;

    -(id) initWithFrame.:(CGRect)frame. andInsets:(UIEdgeInsets)insets {

    self = [super initWithFrame.:frame];

    if(self){

    self.insets = insets;

    }

    return self;

    }

    -(id) initWithInsets:(UIEdgeInsets)insets {

    self = [super init];

    if(self){

    self.insets = insets;

    }

    return self;

    }

    -(void) drawTextInRect:(CGRect)rect {

    return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.insets)];

    }

    @end

    调用部分

    InsetsLabel * lblTitle=[[InsetsLabel alloc] initWithFrame.:CGRectMake(0, 35+25*i, 185, 22)];

    [lblTitle setInsets:UIEdgeInsetsMake(0, 5, 0, 5)];