UIView
self.view.backgroundColor = UIColor.whiteColor; //控制器視圖 背景顏色 白色
UIView *view = [UIView new]; //新建視圖
view.clipsToBounds = YES; //YES超過就裁剪掉 會(huì)裁剪掉陰影
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(負(fù)數(shù)為左,正數(shù)為右) 向下偏移5(負(fù)數(shù)為上辆布,正數(shù)為下)
shadowView.layer.shadowOpacity = 0.8; //透明度
shadowView.layer.shadowRadius = 6; //擴(kuò)散半徑
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 一樣可以設(shè)置背景色渡处、圓角等等
和UIView相比UILabel可以顯示文本
UILabel *label = [UILabel new];
label.clipsToBounds = YES; //YES超過就裁剪掉 會(huì)裁剪掉陰影
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"; //設(shè)置為顯示的文本
label.textColor = UIColor.orangeColor; //設(shè)置文本的顏色 橙色
label.textAlignment = NSTextAlignmentCenter; //居中顯示 默認(rèn)靠左NSTextAlignmentLeft 靠右是NSTextAlignmentRight
label.numberOfLines = 0; //默認(rèn)為1 就是限制1行 2就行是限制2行 0為不限制
label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold]; //字體14號(hào)粗體
[self.view addSubview:label]; //放到控制器視圖里
效果圖
CFC55ADC-B13F-46CD-A458-E2DC255FE5A4.png
// 富文本 自己百度找代碼看效果 學(xué)會(huì)自己解決問題
// label.attributedText =
大致效果圖
872E4CEE-9AAB-4C26-B5EB-4D4F52CB5742.png
UIImageView
UIButton
UIScrollView
UITableView
UICollectionView
UITextField
UITextView