天天看点

iOS-UIKit( UILabel.h - -解读)

NS_ASSUME_NONNULL_BEGIN

@class UIColor,UIFont;

NS_CLASS_AVAILABLE_IOS(2_0)@interface UILabel :UIView <NSCoding>

//设置和读取文本内容,默认为nil

@property(nullable,nonatomic,copy)NSString *text;

//设置字体大小,默认17

@property(null_resettable,nonatomic,strong)UIFont*font;

//设置文字颜色,默认为黑色

@property(null_resettable,nonatomic,strong)UIColor*textColor;

//设置阴影颜色 

@property(nullable,nonatomic,strong)UIColor*shadowColor;

//设置阴影偏移量

@property(nonatomic)CGSize shadowOffset;

//设置标签文本对齐方式。

@property(nonatomic)NSTextAlignment textAlignment;

//设置文字过长时的显示格式

@property(nonatomic)NSLineBreakMode lineBreakMode;

//设置标签属性文本。

@property(nullable,nonatomic,copy)NSAttributedString *attributedText 

//高亮显示时的文本颜色

@property(nullable,nonatomic,strong)UIColor *highlightedTextColor;

//是否高亮显示

@property(nonatomic,getter=isHighlighted)BOOL highlighted; 

//是否可以与用户交互

@property(nonatomic,getter=isUserInteractionEnabled)BOOL userInteractionEnabled; 

//只是决定了Label的绘制方式,将它设置为NO将会使文本变暗,表示它没有激活,这时向它设置颜色值是无效的。

@property(nonatomic,getter=isEnabled)BOOL enabled;

//标签最多显示行数,如果为0则表示多行。

@property(nonatomic)NSInteger numberOfLines;

//设置字体大小适应label宽度 

@property(nonatomic)BOOL adjustsFontSizeToFitWidth; 

//如果adjustsFontSizeToFitWidth属性设置为YES,这个属性就来控制文本基线的行为。

@property(nonatomic)UIBaselineAdjustment baselineAdjustment;

//设置最小收缩比例,如果Label宽度小于文字长度时,文字进行收缩,收缩超过比例后,停止收缩。

@property(nonatomic)CGFloat minimumScaleFactor NS_AVAILABLE_IOS(6_0); 

@property(nonatomic)BOOL allowsDefaultTighteningForTruncation NS_AVAILABLE_IOS(9_0); 

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines;

- (void)drawTextInRect:(CGRect)rect;

@property(nonatomic)CGFloat preferredMaxLayoutWidth NS_AVAILABLE_IOS(6_0);

//设置最小收缩字号,如果Label宽度小于文字长度时,文字字号减小,低于设定字号后,不再减小。6.0以后不再使用了。

@property(nonatomic)CGFloat minimumFontSize NS_DEPRECATED_IOS(2_0, 6_0);

//改变字母之间的间距来适应Label大小

@property(nonatomic)BOOL adjustsLetterSpacingToFitWidth NS_DEPRECATED_IOS(6_0,7_0);

@end

NS_ASSUME_NONNULL_END