Commit bad7f3673631c4b95de4bf9cb43b28ef51c4ef26
1 parent
5ba08f80
短剧主页,简介逻辑优化
Showing
1 changed file
with
25 additions
and
8 deletions
metaCode/Classes/Main/HomePages/View/PlayletHomePage/CNLivePlayletHomePageHeaderCell.swift
| ... | ... | @@ -73,13 +73,19 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 73 | 73 | titleLabel.height = height |
| 74 | 74 | return titleLabel |
| 75 | 75 | }() |
| 76 | + ///简介背景 | |
| 77 | + lazy var jianjieBgView :UIView = { | |
| 78 | + let jianjieBgView = UIView(frame: CGRect(x: self.iconImgView.left, y: self.iconImgView.bottom+10, width: KSreenWidth-2*self.iconImgView.left, height: 21)) | |
| 79 | + jianjieBgView.backgroundColor = UIColor(red:0.98, green:0.98, blue:0.98, alpha:1.00) | |
| 80 | + return jianjieBgView | |
| 81 | + }() | |
| 76 | 82 | ///简介 |
| 77 | 83 | lazy var jianjieLabel: UILabel = { |
| 78 | - let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.left, self.iconImgView.bottom+10, KSreenWidth-2*self.iconImgView.left, 21)) | |
| 84 | + let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.left+10, self.iconImgView.bottom+20, KSreenWidth-2*self.iconImgView.left-13, 21)) | |
| 79 | 85 | titleLabel.textColor = HexColor("#333333") |
| 80 | 86 | titleLabel.textAlignment = .left |
| 81 | 87 | titleLabel.font = Font_12 |
| 82 | - titleLabel.backgroundColor = UIColor(red:0.98, green:0.98, blue:0.98, alpha:1.00) | |
| 88 | + titleLabel.backgroundColor = .clear// UIColor(red:0.98, green:0.98, blue:0.98, alpha:1.00) | |
| 83 | 89 | titleLabel.text = "简介" |
| 84 | 90 | titleLabel.numberOfLines = 0 |
| 85 | 91 | var lines = titleLabel.getRealLabelTextLines() |
| ... | ... | @@ -93,9 +99,9 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 93 | 99 | //展开,收起 |
| 94 | 100 | lazy var expandBtn: UIButton = { |
| 95 | 101 | let expandBtn = UIButton.init(type: .custom) |
| 96 | - expandBtn.backgroundColor = .white | |
| 102 | + expandBtn.backgroundColor = .clear | |
| 97 | 103 | |
| 98 | - expandBtn.frame = CGRect(x: self.jianjieLabel.right-60, y: self.jianjieLabel.bottom, width: 60, height: 30) | |
| 104 | + expandBtn.frame = CGRect(x: self.jianjieBgView.right-60, y: self.jianjieBgView.bottom-10, width: 60, height: 30) | |
| 99 | 105 | expandBtn.setTitle("展开", for: .normal) |
| 100 | 106 | expandBtn.setTitle("收起", for: .selected) |
| 101 | 107 | |
| ... | ... | @@ -168,6 +174,7 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 168 | 174 | self.iconImgView.addSubview(self.payIconImgView) |
| 169 | 175 | self.contentView.addSubview(self.titleLabl) |
| 170 | 176 | self.contentView.addSubview(self.jishuLabel) |
| 177 | + self.contentView.addSubview(self.jianjieBgView) | |
| 171 | 178 | self.contentView.addSubview(self.jianjieLabel) |
| 172 | 179 | self.contentView.addSubview(self.expandBtn) |
| 173 | 180 | self.contentView.addSubview(self.followBtn) |
| ... | ... | @@ -182,7 +189,7 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 182 | 189 | } |
| 183 | 190 | |
| 184 | 191 | self.followBtn.snp.makeConstraints { make in |
| 185 | - make.top.equalTo(self.jianjieLabel.snp.bottom).offset(25) | |
| 192 | + make.top.equalTo(self.jianjieBgView.snp.bottom).offset(25) | |
| 186 | 193 | make.left.equalTo(self.iconImgView.snp.left) |
| 187 | 194 | make.width.equalTo(140) |
| 188 | 195 | make.height.equalTo(40) |
| ... | ... | @@ -267,8 +274,16 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 267 | 274 | |
| 268 | 275 | }else{ |
| 269 | 276 | //收起状态 |
| 270 | - self.jianjieLabel.height = 2*height | |
| 277 | + if lines <= 2{ | |
| 278 | + //小于2行,按实际行数 | |
| 279 | + self.jianjieLabel.height = CGFloat(lines)*height | |
| 280 | + }else{ | |
| 281 | + //大于2行, 显示2行 | |
| 282 | + self.jianjieLabel.height = 2*height | |
| 283 | + } | |
| 271 | 284 | } |
| 285 | + self.jianjieBgView.height = self.jianjieLabel.height+20 | |
| 286 | + self.expandBtn.top = self.jianjieBgView.bottom-10 | |
| 272 | 287 | if model.albumMsgModel!.collection{ |
| 273 | 288 | self.followChangeStatus(isFollowed: true) |
| 274 | 289 | }else{ |
| ... | ... | @@ -289,8 +304,10 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 289 | 304 | //文本展开状态,点击收起 |
| 290 | 305 | self.jianjieLabel.height = 2*height |
| 291 | 306 | } |
| 307 | + self.jianjieBgView.height = self.jianjieLabel.height+20 | |
| 292 | 308 | self.homePageHeaderCellChangedBlock!(self, self.jianjieLabel.height) |
| 293 | - self.expandBtn.top = self.jianjieLabel.bottom | |
| 309 | + | |
| 310 | + self.expandBtn.top = self.jianjieBgView.bottom-10 | |
| 294 | 311 | |
| 295 | 312 | } |
| 296 | 313 | @objc func followBtnAction(button:UIButton){ |
| ... | ... | @@ -390,7 +407,7 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ |
| 390 | 407 | // 这里可以对获取到的子图层进行操作或者访问其属性等 |
| 391 | 408 | return subLayer |
| 392 | 409 | } else { |
| 393 | - print("未找到指定名称的图层") | |
| 410 | +// print("未找到指定名称的图层") | |
| 394 | 411 | return nil |
| 395 | 412 | } |
| 396 | 413 | } | ... | ... |