UILabel的常见属性
- @property(nonatomic,copy) NSString *text;
- @property(nonatomic,retain) UIFont *font;
- @property(nonatomic,retain) UIColor *textColor;
- @property(nonatomic) NSTextAlignment textAlignment;
- @property(nonatomic) NSInteger numberOfLines;
- @property(nonatomic) NSLineBreakMode lineBreakMode;
- BOOL enabled
- CGSize shadowOffset
@property(nonatomic,copy) NSString *text;
- 显示的文字
label1.text=@"这是一个代码创建的label";
@property(nonatomic,retain) UIFont *font;
- 字体
- label1.font=[UIFont boldSystemFontOfSize:20.f];
@property(nonatomic,retain) UIColor *textColor;
- 文字颜色
label1.textColor=[UIColor greenColor];
@property(nonatomic) NSTextAlignment textAlignment;
- 对齐模式(比如左对齐、居中对齐、右对齐)
label1.textAlignment=NSTextAlignmentRight;
@property(nonatomic) NSInteger numberOfLines;
- 文字行数,当行数为0时候,自动成填满控件高度的最大行数。这个属性和可视化界面右边的Lines是同一个属性
label1.numberOfLines=2;
@property(nonatomic) NSLineBreakMode lineBreakMode;
- 换行模式
label1.lineBreakMode=NSLineBreakByTruncatingMiddle;
- NSLineBreakByClipping//把多余的裁减掉,裁剪结尾
- NSLineBreakByWordWrapping //以单词结束换行
- NSLineBreakByCharWrapping, //以字母结束换行
- NSLineBreakByClipping
- NSLineBreakByTruncatingHead, //省略号在开头
- NSLineBreakByTruncatingTail, //省略号在结尾
- NSLineBreakByTruncatingMiddle //省略号在中间

BOOL enabled
是否可用
_label1.enabled=TRUE;//黑色
_label1.enabled=FALSE;//灰色
CGSize shadowOffset
阴影偏移量
label1.shadowOffset=CGSizeMake(1, 2);