一. UIView的学习
1.UIView的常见属性
- UIView *superVIew
- 当前控件的父控件
- NSArray *subviews
- 当前view的子控件集合
- 数组元素的顺序决定子控件的显示层级顺序(下标越大, 显示越在上面)
2. UIView的常见方法
- -(void)addSubview:(UIView *)view;
- 添加子控件
- 在代码执行的顺序中,靠后添加的子控件显示在上面
- 例如: [self.view addsubviews:btn];
- -(void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
- 将控件插入到siblingSubview下面
- -(void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
- 将控件插入到siblingSubview上面
- -(void)bringSubviewToFront:(UIView *)view;
- 将view放在最上面
- -(void)sendSubviewToBack:(UIView *)view;
- 将view放在最下面
二. UILabel的学习
1. UILabel的常见属性
- NSString *text
- 文字属性(字符串)
- 如:self.label.text = @"hello world";
- UIFont *font
- 字体属性
- 如:self.label.font = [UIFont systemFontOfSize:15];
- UIColor *textColor
- 文字颜色属性
- label.textColor = [UIColor blueColor];
- NSTextAlignment textAlignment;
- 文字对齐属性, 这是一个枚举
- 如: self.label.textAlignment = NSTextAlignmentCenter;
- 主要枚举如下:
NSTextAlignmentLeft (靠左)
NSTextAlignmentCenter(居中)
NSTextAlignmentRight (靠右)
NSTextAlignmentCenter
NSTextAlignmentJustified
NSTextAlignmentNatural
- NSInteger numberOfLines
- 换行属性 当设置为0的时候,可以自动换行
- UIColor *backgroundColor
- 背景色设置