标签:mutable iat ++ run lte init ring int ret
创建uilabel的分类
//竖着显示
.h写入
@property (nonatomic) NSString *verticalText;
.m写入
- (NSString *)verticalText{
// 利用runtime添加属性
return objc_getAssociatedObject(self, @selector(verticalText));
}
- (void)setVerticalText:(NSString *)verticalText{
objc_setAssociatedObject(self, &verticalText, verticalText, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
NSMutableString *str = [[NSMutableString alloc] initWithString:verticalText];
NSInteger count = str.length;
for (int i = 1; i < count; i ++) {
[str insertString:@"\n" atIndex:i*2-1];
}
self.text = str;
self.numberOfLines = 0;
}
用法:label.verticalText = @"竖着";
标签:mutable iat ++ run lte init ring int ret
原文地址:http://www.cnblogs.com/tongyuling/p/7111036.html