Commit 29fa9b96bff24aeae152e234770ed5e996f4c383
1 parent
b36ba646
cell阴影效果
Showing
4 changed files
with
61 additions
and
45 deletions
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNDownSlideSingleCourseCell.swift
| @@ -94,13 +94,18 @@ class CNDownSlideSingleCourseCell: UITableViewCell { | @@ -94,13 +94,18 @@ class CNDownSlideSingleCourseCell: UITableViewCell { | ||
| 94 | contentView.addSubview(bgBackView) | 94 | contentView.addSubview(bgBackView) |
| 95 | 95 | ||
| 96 | bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:model.cellH-DownSlideRecommendLeftGap) | 96 | bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:model.cellH-DownSlideRecommendLeftGap) |
| 97 | - bgBackView.layer.shadowColor = HexColor("#000000")?.cgColor | ||
| 98 | - bgBackView.layer.shadowRadius = 12 | 97 | + // 设置阴影效果 |
| 98 | + bgBackView.layer.masksToBounds = false | ||
| 99 | + //定义view的阴影颜色 | ||
| 100 | + bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor | ||
| 101 | + //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的 | ||
| 99 | bgBackView.layer.shadowOpacity = 1 | 102 | bgBackView.layer.shadowOpacity = 1 |
| 103 | + //定义view的阴影宽度,模糊计算的半径 | ||
| 104 | + bgBackView.layer.shadowRadius = 10.0 | ||
| 105 | + //阴影偏移量 | ||
| 100 | bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0) | 106 | bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0) |
| 101 | bgBackView.layer.cornerRadius = 12 | 107 | bgBackView.layer.cornerRadius = 12 |
| 102 | - bgBackView.clipsToBounds = true | ||
| 103 | - bgBackView.backgroundColor = HexColor("#FFFFFF") | 108 | + bgBackView.backgroundColor = .white |
| 104 | 109 | ||
| 105 | let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30)) | 110 | let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30)) |
| 106 | titleLbl.text = model.blockName ?? "全部课程" | 111 | titleLbl.text = model.blockName ?? "全部课程" |
| @@ -154,9 +159,19 @@ class CNDownSlideSingleCourseCell: UITableViewCell { | @@ -154,9 +159,19 @@ class CNDownSlideSingleCourseCell: UITableViewCell { | ||
| 154 | bgBackView.addSubview(bgImageView) | 159 | bgBackView.addSubview(bgImageView) |
| 155 | 160 | ||
| 156 | bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:DownSlideSingleCourseMoreH+DownSlideSingleCourseImgH) | 161 | bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:DownSlideSingleCourseMoreH+DownSlideSingleCourseImgH) |
| 157 | - bgBackView.layer.shadowColor = UIColor.black.cgColor | ||
| 158 | - bgBackView.layer.shadowOpacity = 0.4 | ||
| 159 | - bgBackView.layer.shadowOffset = CGSize(width: 0, height: 1) | 162 | + |
| 163 | + // 设置阴影效果 | ||
| 164 | + bgBackView.layer.masksToBounds = false | ||
| 165 | + //定义view的阴影颜色 | ||
| 166 | + bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor | ||
| 167 | + //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的 | ||
| 168 | + bgBackView.layer.shadowOpacity = 1 | ||
| 169 | + //定义view的阴影宽度,模糊计算的半径 | ||
| 170 | + bgBackView.layer.shadowRadius = 10.0 | ||
| 171 | + //阴影偏移量 | ||
| 172 | + bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0) | ||
| 173 | + bgBackView.layer.cornerRadius = 12 | ||
| 174 | + bgBackView.backgroundColor = .white | ||
| 160 | 175 | ||
| 161 | bgImageView.frame = CGRect(x: 0, y: 0,width:DownSlideSingleCourseW , height:DownSlideSingleCourseImgH) | 176 | bgImageView.frame = CGRect(x: 0, y: 0,width:DownSlideSingleCourseW , height:DownSlideSingleCourseImgH) |
| 162 | bgImageView.contentMode = .scaleAspectFill | 177 | bgImageView.contentMode = .scaleAspectFill |
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNDownSlideView.swift
| @@ -107,15 +107,30 @@ class CNDownSlideView:UIView{ | @@ -107,15 +107,30 @@ class CNDownSlideView:UIView{ | ||
| 107 | bottomView.backgroundColor = HexColor("#FFFFFF") | 107 | bottomView.backgroundColor = HexColor("#FFFFFF") |
| 108 | bottomView.isHidden = true | 108 | bottomView.isHidden = true |
| 109 | 109 | ||
| 110 | - let path:UIBezierPath = UIBezierPath.init(roundedRect: bottomView.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize.init(width: 50, height: 50)) | ||
| 111 | - let maskLayer:CAShapeLayer = CAShapeLayer() | ||
| 112 | - maskLayer.frame = bottomView.bounds | ||
| 113 | - maskLayer.path = path.cgPath | ||
| 114 | - bottomView.layer.mask = maskLayer | ||
| 115 | - bottomView.clipsToBounds = true | 110 | +// let path:UIBezierPath = UIBezierPath.init(roundedRect: bottomView.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize.init(width: 50, height: 50)) |
| 111 | +// let maskLayer:CAShapeLayer = CAShapeLayer() | ||
| 112 | +// maskLayer.frame = bottomView.bounds | ||
| 113 | +// maskLayer.path = path.cgPath | ||
| 114 | +// bottomView.layer.mask = maskLayer | ||
| 115 | +// bottomView.clipsToBounds = true | ||
| 116 | + | ||
| 116 | // bottomView.layer.cornerRadius = 50 | 117 | // bottomView.layer.cornerRadius = 50 |
| 117 | // bottomView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] | 118 | // bottomView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] |
| 118 | 119 | ||
| 120 | + | ||
| 121 | + // 设置阴影效果 | ||
| 122 | + bottomView.layer.masksToBounds = false | ||
| 123 | + //定义view的阴影颜色 | ||
| 124 | + bottomView.layer.shadowColor = UIColor(red: 0.55, green: 0.68, blue: 0.86, alpha: 0.1).cgColor | ||
| 125 | + //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的 | ||
| 126 | + bottomView.layer.shadowOpacity = 1 | ||
| 127 | + //定义view的阴影宽度,模糊计算的半径 | ||
| 128 | + bottomView.layer.shadowRadius = 15.0 | ||
| 129 | + //阴影偏移量 | ||
| 130 | + bottomView.layer.shadowOffset = CGSize(width: 0, height: -3) | ||
| 131 | + bottomView.layer.cornerRadius = 50 | ||
| 132 | + bottomView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] | ||
| 133 | + | ||
| 119 | let backBtn: UIButton = UIButton(type: .custom) | 134 | let backBtn: UIButton = UIButton(type: .custom) |
| 120 | backBtn.frame = CGRectMake(0, 0, 100, DownSlideBottomViewHeight) | 135 | backBtn.frame = CGRectMake(0, 0, 100, DownSlideBottomViewHeight) |
| 121 | backBtn.centerX = bottomView.width/2 | 136 | backBtn.centerX = bottomView.width/2 |
metaCode/Classes/Main/HomePages/Controller/AuthController/CNLiveAuthViewController.swift
| @@ -246,8 +246,8 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa | @@ -246,8 +246,8 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa | ||
| 246 | 246 | ||
| 247 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | 247 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 248 | if self.isHaveDuanJU && indexPath.section == 0{ | 248 | if self.isHaveDuanJU && indexPath.section == 0{ |
| 249 | - //标题55+n个cell*(45+15*2)+首尾15 | ||
| 250 | - return CGFloat(self.duanjuDataArray.count)*(45+15*2)+CGFloat(55)+15+15 | 249 | + //标题55+n个cell*(45+15*2)+首尾15+12圆角 |
| 250 | + return CGFloat(self.duanjuDataArray.count)*(45+15*2)+CGFloat(55)+15+15+12 | ||
| 251 | }else{ | 251 | }else{ |
| 252 | let slideModel = self.dataArray[indexPath.row] as! CNLiveDownSlideModel | 252 | let slideModel = self.dataArray[indexPath.row] as! CNLiveDownSlideModel |
| 253 | return CGFloat(slideModel.cellH) | 253 | return CGFloat(slideModel.cellH) |
metaCode/Classes/Main/HomePages/View/HomePage/CNLiveHomePageDuanJuCell.swift
| @@ -22,18 +22,8 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | @@ -22,18 +22,8 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | ||
| 22 | self.modelArr = NSMutableArray(array: modelArr) | 22 | self.modelArr = NSMutableArray(array: modelArr) |
| 23 | 23 | ||
| 24 | self.tableView.height = CGFloat(self.modelArr.count)*(45+15*2) | 24 | self.tableView.height = CGFloat(self.modelArr.count)*(45+15*2) |
| 25 | - self.totalView.height = CGFloat(self.modelArr.count)*(45+15*2) + 55 | 25 | + self.totalView.height = CGFloat(self.modelArr.count)*(45+15*2) + 55 + 12 |
| 26 | self.tableView.reloadData() | 26 | self.tableView.reloadData() |
| 27 | - | ||
| 28 | -// //定义view的阴影颜色 | ||
| 29 | -// self.totalView.layer.shadowColor = UIColor.black.cgColor | ||
| 30 | -// //阴影偏移量 | ||
| 31 | -// self.totalView.layer.shadowOffset=CGSize(width:1, height:1) | ||
| 32 | -// //定义view的阴影宽度,模糊计算的半径 | ||
| 33 | -// self.totalView.layer.shadowRadius = 12 | ||
| 34 | -// //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的 | ||
| 35 | -// self.totalView.layer.shadowOpacity = 0.4 | ||
| 36 | - | ||
| 37 | } | 27 | } |
| 38 | //MARK: - 懒加载 | 28 | //MARK: - 懒加载 |
| 39 | ///区块标题 | 29 | ///区块标题 |
| @@ -65,22 +55,23 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | @@ -65,22 +55,23 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | ||
| 65 | self.selectionStyle = .none | 55 | self.selectionStyle = .none |
| 66 | 56 | ||
| 67 | self.contentView.addSubview(self.totalView) | 57 | self.contentView.addSubview(self.totalView) |
| 68 | - | ||
| 69 | - self.totalView.addSubview(self.blockTitleLabl) | ||
| 70 | - self.totalView.addSubview(self.tableView) | ||
| 71 | - self.tableView.backgroundColor = .white | 58 | + |
| 59 | + // 设置阴影效果 | ||
| 60 | + self.totalView.layer.masksToBounds = false | ||
| 61 | + //定义view的阴影颜色 | ||
| 62 | + self.totalView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor | ||
| 63 | + //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的 | ||
| 64 | + self.totalView.layer.shadowOpacity = 1 | ||
| 65 | + //定义view的阴影宽度,模糊计算的半径 | ||
| 66 | + self.totalView.layer.shadowRadius = 10.0 | ||
| 67 | + //阴影偏移量 | ||
| 68 | + self.totalView.layer.shadowOffset = CGSize(width: 0, height: 0) | ||
| 69 | + | ||
| 72 | self.totalView.layer.cornerRadius = 12 | 70 | self.totalView.layer.cornerRadius = 12 |
| 73 | - self.totalView.clipsToBounds = true | ||
| 74 | self.totalView.backgroundColor = .white | 71 | self.totalView.backgroundColor = .white |
| 75 | 72 | ||
| 76 | - //定义view的阴影颜色 | ||
| 77 | - self.totalView.layer.shadowColor = UIColor.black.cgColor | ||
| 78 | - //阴影偏移量 | ||
| 79 | - self.totalView.layer.shadowOffset=CGSize(width:1, height:1) | ||
| 80 | - //定义view的阴影宽度,模糊计算的半径 | ||
| 81 | - self.totalView.layer.shadowRadius = 12 | ||
| 82 | - //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的 | ||
| 83 | - self.totalView.layer.shadowOpacity = 0.4 | 73 | + self.totalView.addSubview(self.blockTitleLabl) |
| 74 | + self.totalView.addSubview(self.tableView) | ||
| 84 | 75 | ||
| 85 | setupUI() | 76 | setupUI() |
| 86 | } | 77 | } |
| @@ -90,7 +81,7 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | @@ -90,7 +81,7 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | ||
| 90 | } | 81 | } |
| 91 | 82 | ||
| 92 | private func setupUI() { | 83 | private func setupUI() { |
| 93 | - contentView.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex) | 84 | + contentView.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex) |
| 94 | } | 85 | } |
| 95 | 86 | ||
| 96 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | 87 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| @@ -114,9 +105,4 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | @@ -114,9 +105,4 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa | ||
| 114 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | 105 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 115 | return 45+15*2 | 106 | return 45+15*2 |
| 116 | } | 107 | } |
| 117 | - //MARK: - 事件 | ||
| 118 | - @objc func playBtnAction(){ | ||
| 119 | - showLoading(message: "") | ||
| 120 | -// self.getAlbumList() | ||
| 121 | - } | ||
| 122 | } | 108 | } |