ios 开发速成版

UIView

self.view.backgroundColor = UIColor.whiteColor; //控制器视图 背景颜色 白色

UIView *view = [UIView new]; //新建视图
view.clipsToBounds = YES; //YES超过就裁剪掉 会裁剪掉阴影
view.frame = CGRectMake(50, 100, 80, 100); //位置大小
view.backgroundColor = UIColor.redColor; //背景颜色 红色
view.layer.cornerRadius = 8; //圆角
view.layer.borderWidth = 2; //边框
view.layer.borderColor = UIColor.greenColor.CGColor; //边框颜色 绿色
[self.view addSubview:view]; //放到控制器视图里

UIView *shadowView = [UIView new];
shadowView.frame = CGRectMake(50, 250, 80, 100);
shadowView.backgroundColor = UIColor.yellowColor;
shadowView.layer.shadowOffset = CGSizeMake(-4, 5); //向左偏移4(负数为左,正数为右) 向下偏移5(负数为上,正数为下)
shadowView.layer.shadowOpacity = 0.8; //透明度
shadowView.layer.shadowRadius = 6; //扩散半径
shadowView.layer.shadowColor = UIColor.greenColor.CGColor;
[self.view addSubview:shadowView];

效果图


Simulator Screen Shot - iPhone SE - 2019-11-18 at 11.34.19.png

UILabel

继承UIView 一样可以设置背景色、圆角等等
和UIView相比UILabel可以显示文本

UILabel *label = [UILabel new];
label.clipsToBounds = YES; //YES超过就裁剪掉 会裁剪掉阴影
label.frame = CGRectMake(50, 100, 120, 100); //位置大小
label.backgroundColor = UIColor.redColor; //背景颜色 红色
label.layer.cornerRadius = 8; //圆角
label.layer.borderWidth = 2; //边框
label.layer.borderColor = UIColor.greenColor.CGColor; //边框颜色 绿色
label.text = @"Hello World"; //设置为显示的文本
label.textColor = UIColor.orangeColor; //设置文本的颜色 橙色
label.textAlignment = NSTextAlignmentCenter; //居中显示 默认靠左NSTextAlignmentLeft 靠右是NSTextAlignmentRight
label.numberOfLines = 0; //默认为1 就是限制1行 2就行是限制2行 0为不限制
label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold]; //字体14号粗体
[self.view addSubview:label]; //放到控制器视图里

效果图


CFC55ADC-B13F-46CD-A458-E2DC255FE5A4.png

// 富文本 自己百度找代码看效果 学会自己解决问题
// label.attributedText =
大致效果图


872E4CEE-9AAB-4C26-B5EB-4D4F52CB5742.png

UIImageView

UIButton

UIScrollView

UITableView

UICollectionView

UITextField

UITextView

你可能感兴趣的:(ios 开发速成版)