Commit 6b96f32a1b187307db2ed898c51d7361cd6f1506
1 parent
2536d551
昵称被挤压问题修复
Showing
2 changed files
with
25 additions
and
23 deletions
metaCode/Classes/Main/VideoPage/Model/CNLiveShortVideoHomeModel.swift
| ... | ... | @@ -31,8 +31,8 @@ class ShortVideoHomeCommentListModel: BaseModel { |
| 31 | 31 | tableView_h += replyModel.cellH |
| 32 | 32 | } |
| 33 | 33 | if replyData.replyCount ?? 0 > 2 { |
| 34 | - tableView_top += 30.0 | |
| 35 | - cell_h += 30 | |
| 34 | + tableView_top += adapt_length(length: 30) | |
| 35 | + cell_h += adapt_length(length: 30) | |
| 36 | 36 | } |
| 37 | 37 | cell_h += tableView_h |
| 38 | 38 | } |
| ... | ... | @@ -60,7 +60,7 @@ class ShortVideoHomeCommentFListModel: BaseModel { |
| 60 | 60 | var iconSize: CGSize = CGSize(width: 50, height: 50) |
| 61 | 61 | var textLayout: YYTextLayout! |
| 62 | 62 | var nickLayout: YYTextLayout! |
| 63 | - var cellH: CGFloat! = 50.0 | |
| 63 | + var cellH: CGFloat! = adapt_length(length: 50) | |
| 64 | 64 | |
| 65 | 65 | override func didFinishMapping() { |
| 66 | 66 | super.didFinishMapping() |
| ... | ... | @@ -72,17 +72,18 @@ class ShortVideoHomeCommentFListModel: BaseModel { |
| 72 | 72 | let attributes = NSMutableAttributedString(attributedString: temp_string) |
| 73 | 73 | attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")!, range: NSRange(location: 0, length: temp_string.length)) |
| 74 | 74 | attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: temp_string.length)) |
| 75 | - let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80, height: CGFloat(HUGE))) | |
| 75 | + let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 80), height: CGFloat(HUGE))) | |
| 76 | 76 | textContainer.linePositionModifier = modifier; |
| 77 | 77 | let textLayout = YYTextLayout(container: textContainer, text: attributes) |
| 78 | 78 | self.textLayout = textLayout |
| 79 | 79 | self.cellH += (textLayout?.textBoundingRect.size.height ?? 0) |
| 80 | 80 | |
| 81 | + let nick_modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: medium_adapt_font(pointSize: 12), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5) | |
| 81 | 82 | let textAttributedString = NSMutableAttributedString.init(string: self.nick ?? "") |
| 82 | 83 | textAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#AFAFAF")!, range: NSRange(location: 0, length: textAttributedString.length)) |
| 83 | 84 | textAttributedString.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 12), range: NSRange(location: 0, length: textAttributedString.length)) |
| 84 | - let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80, height: 20)) | |
| 85 | - nickContainer.linePositionModifier = modifier; | |
| 85 | + let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 80), height: CGFloat(HUGE))) | |
| 86 | + nickContainer.linePositionModifier = nick_modifier; | |
| 86 | 87 | self.nickLayout = YYTextLayout(container: nickContainer, text: textAttributedString) |
| 87 | 88 | self.cellH += (self.nickLayout?.textBoundingRect.size.height ?? 0) |
| 88 | 89 | } |
| ... | ... | @@ -115,7 +116,7 @@ class ShortVideoHomeCommentRListItemModel: BaseModel { |
| 115 | 116 | |
| 116 | 117 | var textLayout: YYTextLayout! |
| 117 | 118 | var nickLayout: YYTextLayout! |
| 118 | - var cellH: CGFloat! = 50.0 | |
| 119 | + var cellH: CGFloat! = adapt_length(length: 50) | |
| 119 | 120 | |
| 120 | 121 | override func didFinishMapping() { |
| 121 | 122 | super.didFinishMapping() |
| ... | ... | @@ -127,18 +128,19 @@ class ShortVideoHomeCommentRListItemModel: BaseModel { |
| 127 | 128 | let attributes = NSMutableAttributedString(attributedString: temp_string) |
| 128 | 129 | attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")!, range: NSRange(location: 0, length: temp_string.length)) |
| 129 | 130 | attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: temp_string.length)) |
| 130 | - let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80-40, height: CGFloat(HUGE))) | |
| 131 | + let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 120), height: CGFloat(HUGE))) | |
| 131 | 132 | textContainer.linePositionModifier = modifier; |
| 132 | 133 | self.textLayout = YYTextLayout(container: textContainer, text: attributes) |
| 133 | 134 | self.cellH += (self.textLayout?.textBoundingRect.size.height ?? 0) |
| 134 | 135 | |
| 136 | + let nick_modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: medium_adapt_font(pointSize: 12), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5) | |
| 135 | 137 | let textAttributedString = NSMutableAttributedString.init(string: "\(self.fromNick ?? "") ?? \(self.toNick ?? "")") |
| 136 | 138 | textAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#AFAFAF")!, range: NSRange(location: 0, length: textAttributedString.length)) |
| 137 | 139 | textAttributedString.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 12), range: NSRange(location: 0, length: textAttributedString.length)) |
| 138 | 140 | let attachText = NSAttributedString.yy_attachmentString(withContent: UIImage(named: "short_video_reply_name"), contentMode: .scaleAspectFill, attachmentSize: CGSize(width: adapt_length(length: 8), height: adapt_length(length: 8)), alignTo: medium_adapt_font(pointSize: 12), alignment: .center) |
| 139 | 141 | textAttributedString.replaceCharacters(in: NSRange(location: self.fromNick!.count + 2, length: 2), with: attachText) |
| 140 | - let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80-40, height: 20)) | |
| 141 | - nickContainer.linePositionModifier = modifier; | |
| 142 | + let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 120), height: adapt_length(length: 40))) | |
| 143 | + nickContainer.linePositionModifier = nick_modifier; | |
| 142 | 144 | self.nickLayout = YYTextLayout(container: nickContainer, text: textAttributedString) |
| 143 | 145 | self.cellH += (self.nickLayout?.textBoundingRect.size.height ?? 0) |
| 144 | 146 | } | ... | ... |
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCommentListView.swift
| ... | ... | @@ -526,7 +526,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 526 | 526 | contentView.addSubview(likeButton) |
| 527 | 527 | likeButton.snp.makeConstraints { make in |
| 528 | 528 | make.right.equalToSuperview().offset(-10) |
| 529 | - make.height.equalTo(20) | |
| 529 | + make.height.equalTo(adapt_length(length: 20)) | |
| 530 | 530 | make.width.equalTo(50) |
| 531 | 531 | make.top.equalTo(commentLabel.snp.bottom).offset(10) |
| 532 | 532 | } |
| ... | ... | @@ -534,19 +534,19 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 534 | 534 | timeLabel.snp.makeConstraints { make in |
| 535 | 535 | make.top.equalTo(commentLabel.snp.bottom).offset(10) |
| 536 | 536 | make.left.equalTo(titleLabel.snp.left) |
| 537 | - make.height.equalTo(20) | |
| 537 | + make.height.equalTo(adapt_length(length: 20)) | |
| 538 | 538 | } |
| 539 | 539 | contentView.addSubview(replyButton) |
| 540 | 540 | replyButton.snp.makeConstraints { make in |
| 541 | 541 | make.left.equalTo(timeLabel.snp.right).offset(10) |
| 542 | - make.height.equalTo(20) | |
| 542 | + make.height.equalTo(adapt_length(length: 20)) | |
| 543 | 543 | make.width.equalTo(40) |
| 544 | 544 | make.top.equalTo(commentLabel.snp.bottom).offset(10) |
| 545 | 545 | } |
| 546 | 546 | contentView.addSubview(deleteButton) |
| 547 | 547 | deleteButton.snp.makeConstraints { make in |
| 548 | 548 | make.left.equalTo(replyButton.snp.right).offset(adapt_length(length: 5)) |
| 549 | - make.height.equalTo(20) | |
| 549 | + make.height.equalTo(adapt_length(length: 20)) | |
| 550 | 550 | make.width.equalTo(40) |
| 551 | 551 | make.top.equalTo(commentLabel.snp.bottom).offset(10) |
| 552 | 552 | } |
| ... | ... | @@ -554,7 +554,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 554 | 554 | replyUnfoldButton.snp.makeConstraints { make in |
| 555 | 555 | make.top.equalTo(timeLabel.snp.bottom) |
| 556 | 556 | make.left.equalTo(titleLabel.snp.left) |
| 557 | - make.height.equalTo(30) | |
| 557 | + make.height.equalTo(adapt_length(length: 30)) | |
| 558 | 558 | } |
| 559 | 559 | contentView.addSubview(tableView) |
| 560 | 560 | } |
| ... | ... | @@ -585,20 +585,20 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 585 | 585 | } |
| 586 | 586 | DispatchQueue.main.async {[weak self] in |
| 587 | 587 | guard let self = self else { return } |
| 588 | - self.commentLabel.textLayout = commentData.textLayout | |
| 589 | - self.commentLabel.snp.remakeConstraints { make in | |
| 590 | - make.top.equalTo(self.titleLabel.snp.bottom).offset(10) | |
| 591 | - make.left.equalTo(self.iconView.snp.right).offset(10) | |
| 592 | - make.right.equalToSuperview().offset(-10) | |
| 593 | - make.height.equalTo(commentData.textLayout.textBoundingRect.size.height) | |
| 594 | - } | |
| 595 | 588 | self.titleLabel.textLayout = commentData.nickLayout |
| 596 | 589 | self.titleLabel.snp.remakeConstraints { make in |
| 597 | 590 | make.left.equalTo(self.iconView.snp.right).offset(10) |
| 598 | - make.top.equalToSuperview().offset(10) | |
| 591 | + make.top.equalToSuperview().offset(adapt_length(length: 10)) | |
| 599 | 592 | make.right.equalToSuperview().offset(-10) |
| 600 | 593 | make.height.equalTo(commentData.nickLayout.textBoundingRect.size.height) |
| 601 | 594 | } |
| 595 | + self.commentLabel.textLayout = commentData.textLayout | |
| 596 | + self.commentLabel.snp.remakeConstraints { make in | |
| 597 | + make.top.equalTo(self.titleLabel.snp.bottom).offset(adapt_length(length: 10)) | |
| 598 | + make.left.equalTo(self.iconView.snp.right).offset(10) | |
| 599 | + make.right.equalToSuperview().offset(-10) | |
| 600 | + make.height.equalTo(commentData.textLayout.textBoundingRect.size.height) | |
| 601 | + } | |
| 602 | 602 | self.tableView.snp.removeConstraints() |
| 603 | 603 | self.tableView.removeFromSuperview() |
| 604 | 604 | if replyData.replyCount ?? 0 > 0 { | ... | ... |