
手稿
如何设置呢,方法也比较多,今天给出一个方法,也就是重写label的drawInRect方法
新建一个label记成于UILabel
接下来是重点也就是重写drawInRect方法
- (instancetype)init
{
self = [super init];
return self;
}
- (id)initWithFrame:(CGRect)frame {
return [super initWithFrame:frame];
}
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
CGRect textRect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
textRect.origin.y = bounds.origin.y;
return textRect;
}
-(void)drawTextInRect:(CGRect)requestedRect {
CGRect actualRect = [self textRectForBounds:requestedRect limitedToNumberOfLines:self.numberOfLines];
[super drawTextInRect:actualRect];
}
文章均来自互联网如有不妥请联系作者删除QQ:314111741 地址:http://www.mqs.net/post/14827.html
添加新评论