UILabel的一些常用屬性
// 賦值
UILabel *nameLabel = [[UILabel alloc]init];
// text 賦值
nameLabel.text = @"name";
// 設置文字的顏色
nameLabel.textColor = [UIColor redColor];
// 設置文字的位置(對齊方式)
nameLabel.textAlignment = UITextAlignmentCenter;
// 設置字體適應label 寬度
nameLabel.adjustsFontSizeToFitWidth = YES;
// 設置label的行數
nameLabel.numberOfLines = 2;
// 去掉背景色 或者 設置背景色
nameLabel.backgroundColor = [UIColor clearColor];
// 設置高亮 以及 高亮狀態下的顏色
nameLabel.highlighted = YES;
nameLabel.highlightedTextColor = [UIColor redColor];
// 設置陰影 以及 陰影偏移量
nameLabel.shadowColor = [UIColor grayColor];
nameLabel.shadowOffset = CGSizeMake(1.0, 1.0);
// 設置是否與用戶進行交互
nameLabel.userInteractionEnabled = YES;
// 設置label中的文字是否可變 默認是YES
nameLabel.enabled = NO;
// 文字過長時的顯示格式
/*
typedef NS_ENUM(NSInteger, NSLineBreakMode) {
NSLineBreakByWordWrapping = 0, // Wrap at word boundaries, default
NSLineBreakByCharWrapping, // Wrap at character boundaries
NSLineBreakByClipping, // Simply clip 截去多余部分
NSLineBreakByTruncatingHead, // Truncate at head of line: "...wxyz" 截去頭部
NSLineBreakByTruncatingTail, // Truncate at tail of line: "abcd..." 截去尾部
NSLineBreakByTruncatingMiddle // Truncate middle of line: "ab...yz" 截去中間
} NS_ENUM_AVAILABLE(10_0, 6_0);
*/
nameLabel.lineBreakMode = NSLineBreakByWordWrapping;
//如果adjustsFontSizeToFitWidth屬性設置為YES,這個屬性就來控制文本基線的行為
nameLabel.baselineAdjustment = UIBaselineAdjustmentNone;
/*
UIBaselineAdjustmentAlignBaselines = 0, // default. used when shrinking text to position based on the original baseline
UIBaselineAdjustmentAlignCenters,
UIBaselineAdjustmentNone,
*/