1.text:设置标签显示文本。
2.attributedText:设置标签属性文本。
示例Source:
NSString *text = @"first"; NSMutableAttributedString *textLabelStr = [[NSMutableAttributedString alloc] initWithString:text]; [textLabelStr setAttributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor], NSFontAttributeName : [UIFont systemFontOfSize:17]} range:NSMakeRange(11, 10)];
3.font:设置标签文本字体。
示例Source:
label.font = [UIFont systemFontOfSize:17];
label.font = [UIFont fontWithName:@"Arial" size:16];
label.textColor = [UIColor blueColor];
4.textAlignment:设置标签文本对齐方式。
示例Source:
label.textAlignment = NSTextAlignmentCenter;
5.lineBreakMode:设置标签文字过长时的显示方式,这个属性使用于label中文本的换行和截短。首先numberofLines必须设置为0,才有效果。
示例Source:
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakByCharWrapping; //以字符为显示单位显示,后面部分省略不显示。
label.lineBreakMode = NSLineBreakByClipping; //剪切与文本宽度相同的内容长度,后半部分被删除。
label.lineBreakMode = NSLineBreakByTruncatingHead; //前面部分文字以……方式省略,显示尾部文字内容。
label.lineBreakMode = NSLineBreakByTruncatingMiddle; //中间的内容以……方式省略,显示头尾的文字内容。
label.lineBreakMode = NSLineBreakByTruncatingTail; //结尾部分的内容以……方式省略,显示头的文字内容。
label.lineBreakMode = NSLineBreakByWordWrapping; //以单词为显示单位显示,后面部分省略不显示。
6.enabled:设置文字内容是否可变。
7.adjustsFontSizeToFitWidth:文字内容自适应标签宽度。
8.adjustsLetterSpacingToFitWidth:根据字母的间隔自适应标签宽度,超出部分以……显示。
9.numberOfLines:标签最多显示行数。
10.highlightedTextColor:设置文本高亮显示颜色,与highlighted一起使用。
11.shadowColor:设置文本阴影颜色。
12.shadowOffset:设置文本阴影与原文本的偏移量。用法:label.shadowOffset =CGSizeMake(1.0, 5.0);
13.userInteractionEnabled:设置标签是否忽略或移除用户交互。默认为NO。
14.preferredMaxLayoutWidth:优先选择标签布局的最大宽度。
15.baselineAdjustment:如果adjustsFontSizeToFitWidth属性设置为YES,这个属性就来控制文本基线的行为。
示例Source:
label.baselineAdjustment = UIBaselineAdjustmentNone;
UIBaselineAdjustmentAlignBaselines,默认,文本最上端与中线对齐。
UIBaselineAdjustmentAlignCenters, 文本中线与label中线对齐。
UIBaselineAdjustmentNone, 文本最低端与label中线对齐。
16. backgroundColor 背景颜色
1.UIView
// 如果userInteractionEnabled=NO,不能跟用户交互
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
// 控件的标记(父控件通过标记可以找到对应的子控件)
@property(nonatomic) NSInteger tag;
// 控件的位置和尺寸(以父控件的左上角为坐标原点)
@property(nonatomic) CGRect frame;
// 控件的位置和尺寸(以控件本身的左上角为坐标原点)
@property(nonatomic) CGRect bounds;
// 控件的中点位置(以父控件的左上角为坐标原点)
@property(nonatomic) CGPoint center;
// 形变属性:旋转、缩放、平移
@property(nonatomic) CGAffineTransform transform;
// 父控件
@property(nonatomic,readonly) UIView *superview;
// 所有的子控件
@property(nonatomic,readonly,copy) NSArray *subviews;
2.UILabel
// 显示的文字
@property(nonatomic,copy) NSString *text;
// 字体
@property(nonatomic,retain) UIFont *font;
// 文字颜色
@property(nonatomic,retain) UIColor *textColor;
// 文字的排列方式(左对齐、居中、右对齐)
@property(nonatomic) NSTextAlignment textAlignment;
// 设置行数(行数==0代表自动换行)
@property(nonatomic) NSInteger numberOfLines;
3.UIImageView
// 显示的图片
@property(nonatomic,retain) UIImage *image;
// 设置序列帧图片数组(按顺序播放animationImages数组中的图片)
@property(nonatomic,copy) NSArray *animationImages;
// 序列帧动画的持续时间
@property(nonatomic) NSTimeInterval animationDuration;
// 序列帧动画的执行字数(默认是0,代表无限循环)
@property(nonatomic) NSInteger animationRepeatCount;
4.UIScrollView
// 表示UIScrollView所滚动的位置
@property(nonatomic) CGPoint contentOffset;
// 表示UIScrollView的内容尺寸(能滚动的范围)
@property(nonatomic) CGSize contentSize;
// 增加UIScrollView额外的边缘滚动区域
@property(nonatomic) UIEdgeInsets contentInset;
// 代理
@property(nonatomic,assign) id delegate;
5.UITableView
(前几篇博客已经有很详细的属性介绍及使用) 需要查看的可以参考前几篇博客。
6.UIPickerView
(前几篇博客已经有很详细的属性介绍及使用) 需要查看的可以参考前几篇博客。
7.UIControl
// 是否可用
@property(nonatomic,getter=isEnabled) BOOL enabled;
// 自动拥有很多种状态
// 可以通过下面的方法来监听控件内部的一些事件:点击、值改变
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
1> UIDatePicker
// 设置模式(类型)
@property(nonatomic) UIDatePickerMode datePickerMode;
// 设置区域(zh_CN代表天朝)
@property(nonatomic,retain) NSLocale *locale;
// 设置当前时间
@property(nonatomic,retain) NSDate *date;
// UIDatePicker内部显示的日期更改了,就会触发值改变事件
2> UISwitch
// 控制开关状态
@property(nonatomic,getter=isOn) BOOL on;
- (void)setOn:(BOOL)on animated:(BOOL)animated;
// UISwitch内部开关状态更改了,就会触发值改变事件
3> UISegmentControl
// 一共有多少块区域
@property(nonatomic,readonly) NSUInteger numberOfSegments;
// 当前选中区域的位置
@property(nonatomic) NSInteger selectedSegmentIndex;
// UISegmentControl内部选中的区域更改了,就会触发值改变事件
4> UISlider
// 设置当前的进度值
@property(nonatomic) float value;
// 设置最小的进度值
@property(nonatomic) float minimumValue;
// 设置最大的进度值
@property(nonatomic) float maximumValue;
// UISlider内部的进度值更改了,就会触发值改变事件
5> UIButton
// 快速创建一个按钮
+ (id)buttonWithType:(UIButtonType)buttonType;
// 设置按钮的内边距
@property(nonatomic) UIEdgeInsets contentEdgeInsets;
// 按钮内部的标签控件
@property(nonatomic,readonly,retain) UILabel *titleLabel;
// 按钮内部的图片控件
@property(nonatomic,readonly,retain) UIImageView *imageView;
// 设置内部titleLabel显示的文字
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
// 设置内部titleLabel的文字颜色
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;
// 设置内部imageView显示的图片
- (void)setImage:(UIImage *)image forState:(UIControlState)state;
// 设置背景图片
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;
- (NSString *)titleForState:(UIControlState)state;
- (UIColor *)titleColorForState:(UIControlState)state;
- (UIImage *)imageForState:(UIControlState)state;
- (UIImage *)backgroundImageForState:(UIControlState)state;
6> UITextField(通过delegate监听内部的事件)
8.UIAlertView
// 创建一个UIAlertView对话框
/*
title : 对话框标题
message : 对话框中间显示的文字内容
cancelButtonTitle : 取消按钮的文字
otherButtonTitles : 其他按钮的文字(设置多个)
delegate : 用来监听alertView上面按钮的点击
学习ios 重要还是要理清楚思路 在做或者看老师代码的时候 自己多想想为什么 不要自己看着就抄 另外还是要推荐一下 蓝懿IOS这个培训机构 和刘国斌老师刘国斌老师还是很有名气的,听朋友说刘老师成立了蓝懿iOS,,老师讲课方式很独特,能够尽量让每个人都能弄明白,有的比较难懂的地方,如果有的地方还是不懂得话,老师会换个其它方法再讲解,这对于我们这些学习iOS的同学是非常好的,多种方式的讲解会理解得更全面,这个必须得给个赞,嘻嘻,还有就是这里的学习环境很好,很安静,可以很安心的学习,安静的环境是学习的基础,小班讲课,每个班20几个学生,学习氛围非常好,每天都学到9点多才离开教室,练习的时间很充裕,而且如果在练习的过程中有什么困难,随时可以向老师求助,不像其它机构,通过视频教学,有的甚至学完之后都看不到讲师本人,问点问题都不方便,这就是蓝懿与其它机构的区别,相信在刘国斌老师的细心指导下,每个蓝懿学员都能找到满意的工作,加油!
写博客第八十三天;
QQ:565803433