UILabel与UIFont的用法和属性的一些总结
2015-08-08 15:31
218 查看
初始化一个UILabel对象,并初始化大小
UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
设置显示的文字
label.text=@"123";
和字体相关的一个类,字号大小默认17
@property(nonatomic,retain) UIFont*font;
?
设置字体颜色
label.textColor=[UIColor redColor];
设置阴影偏移量
label.shadowOffset=CGSizeMake(20, 20);
设置阴影颜色
label.shadowColor=[UIColor blackColor];
设置对齐模式
label.textAlignment=NSTextAlignmentJustified;
?
多行文本设置
label.lineBreakMode=NSLineBreakByCharWrapping;
?
使用attributedText绘制
@property(nonatomic,copy) NSAttributedString *attributedText
设置高亮的字体颜色
label.highlightedTextColor=[UIColor blueColor];
//设置是否高亮
label.highlighted=YES;
用户交互 默认关闭
label.userInteractionEnabled=NO;
是否有效,默认是YES,无效为灰色
label.enabled=NO;
显示的行数,0为无限
@property(nonatomic) NSInteger numberOfLines;
宽度自适应大小 默认是NO
@property(nonatomic) BOOL adjustsFontSizeToFitWidth;
字符适应宽度:不赞成使用
@property(nonatomic) BOOL adjustsLetterSpacingToFitWidth
最小适应大小2.0-6.0
@property(nonatomic) CGFloat minimumFontSize
最小适应大小 6.0 之后
@property(nonatomic) CGFloat minimumScaleFactor
垂直方向的调整
@property(nonatomic) UIBaselineAdjustment baselineAdjustment;
?
返回文本绘制矩形
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines;
文本绘制函数
- (void)drawTextInRect:(CGRect)rect
文本自动布局参数
@property(nonatomic) CGFloat preferredMaxLayoutWidth
UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
设置显示的文字
label.text=@"123";
和字体相关的一个类,字号大小默认17
@property(nonatomic,retain) UIFont*font;
?
label.textColor=[UIColor redColor];
设置阴影偏移量
label.shadowOffset=CGSizeMake(20, 20);
设置阴影颜色
label.shadowColor=[UIColor blackColor];
设置对齐模式
label.textAlignment=NSTextAlignmentJustified;
?
label.lineBreakMode=NSLineBreakByCharWrapping;
?
@property(nonatomic,copy) NSAttributedString *attributedText
设置高亮的字体颜色
label.highlightedTextColor=[UIColor blueColor];
//设置是否高亮
label.highlighted=YES;
用户交互 默认关闭
label.userInteractionEnabled=NO;
是否有效,默认是YES,无效为灰色
label.enabled=NO;
显示的行数,0为无限
@property(nonatomic) NSInteger numberOfLines;
宽度自适应大小 默认是NO
@property(nonatomic) BOOL adjustsFontSizeToFitWidth;
字符适应宽度:不赞成使用
@property(nonatomic) BOOL adjustsLetterSpacingToFitWidth
最小适应大小2.0-6.0
@property(nonatomic) CGFloat minimumFontSize
最小适应大小 6.0 之后
@property(nonatomic) CGFloat minimumScaleFactor
垂直方向的调整
@property(nonatomic) UIBaselineAdjustment baselineAdjustment;
?
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines;
文本绘制函数
- (void)drawTextInRect:(CGRect)rect
文本自动布局参数
@property(nonatomic) CGFloat preferredMaxLayoutWidth
相关文章推荐
- 蓝牙协议(bluetooth spec)
- UIActivityIndicatorView控件的属性和方法
- UIProgress控件的属性和方法
- UIPageControll 的属性和用法
- Ultra-QuickSort
- IOS中UIAlertView(警告框)常用方法总结
- 【简单dp】poj 2127 Greatest Common Increasing Subsequence【最长公共上升子序列】【模板】
- IOS中UIActionSheet使用方法详解
- 手机开发之H5+规范的原生UI警示框
- UITextField
- 2015多校第四场1003 hdu 5329 Question for the Leader
- Android编译failed to find Build Tools revision 23.0.0 rc2解决
- UITableView控件使用总结
- String.valueOf传null参数的不同表现
- 解决“同一UIView中有多个UITableView时点击状态栏不能置顶”问题
- UIButton的实现(含有边框)
- iOS 中 UITextView 限制最大输入字数
- iOS开发UIScrollView常见属性和方法
- iOS UI控件之间的关系图
- iOS中UIPickerView常见属性和方法的总结