UILabel的使用
// 初始化UILabel
UILabel *able = [[UILabel alloc]initWithFrame:CGRectMake(10, 200, 200, 30)];
//设置字体颜色 (用RGB的方式)
able.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
//设置字体颜色
able.textColor = [UIColor blackColor];
//给UILabel添加文字
able.text = @"用户名:";
//设置Label的frame (位置)
able.frame = CGRectMake(50, 200, 100, 35);
齐方式,居中对齐等等,是个枚举类型
able.textAlignment = NSTextAlignmentCenter;
// //设置lable字体大小,默认为17;这里设置为10;
able.font = [UIFont systemFontOfSize:20];
//打印所有字体
NSLog(@"%@",[UIFont familyNames]);
//将lable的宽度设置为100;
able.frame = CGRectMake(50, 150, 100, 35);
//换行模式,也是一个枚举,(按住command点击lineBreakMode)
able.lineBreakMode = NSLineBreakByTruncatingHead;
//写为0会自动适应
able.numberOfLines = 0;
//lable的大小自适应
[able sizeToFit];
//将lable加到窗口上
[self.window addSubview:able];
//阴影颜色
able.shadowColor = [UIColor blackColor];
able.shadowOffset = CGSizeMake(0, 0);
//圆角
//设置圆角弧度
able.layer.cornerRadius = 6;
//shez边界的颜色
able.layer.borderColor = [[UIColor whiteColor]CGColor];
//设置边界的宽度
able.layer.borderWidth = 2;
//对超出弧度进行裁剪
//一个是对able进行裁剪
able.clipsToBounds = YES;
//这个是对layer层的操作
able.layer.masksToBounds = YES;