UILable
summary
UILabel极其常用,功能比较专一:显示文字
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;
换行模式
UIFont类
UIFont代表字体
+(UIFont *)systemFontOfSize:(CGFloat)fontSize; 系统默认字体
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 粗体
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 斜体
Demo
// 改变文本的内容
self.label.text = @"我是红色";
//设置lebel背景颜色
self.textLbel.backgroundColor = [UIColor grayColor];
// 文字居中
self.label.textAlignment = NSTextAlignmentCenter;
//设置lebel字体大小 系统字体
self.textLbel.font = [UIFont systemFontOfSize:19.f];
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 粗体
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 斜体
//设置lebel字体颜色
self.textLbel.textColor = [UIColor blackColor];
//设置lebel字体对其方式
self.textLbel.textAlignment = NSTextAlignmentCenter;
//设置lebel字体阴影颜色
self.textLbel.shadowColor = [UIColor blueColor];
//设置lebel字体偏移量
self.textLbel.shadowOffset = CGSizeMake(-2, 3);
//设置lebel行数 0表示自动换行
self.textLbel.numberOfLines = 0;
//设置lebel字体显示方式
self.textLbel.lineBreakMode = NSLineBreakByTruncatingTail;