|
@@ -64,8 +64,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
topicView.topicArray = self.videoItemMdl?.topic
|
|
|
topicView.reloadData()
|
|
|
|
|
|
-
|
|
|
-// content string 内容
|
|
|
+ contentLabel.text = self.videoItemMdl?.content
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -85,7 +84,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
cell.indexPath = indexPath
|
|
|
return cell
|
|
|
}
|
|
|
- //MARK: - indexPath
|
|
|
+ //MARK: indexPath
|
|
|
var indexPath: IndexPath?{
|
|
|
didSet {
|
|
|
|
|
@@ -136,6 +135,13 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
// 话题View
|
|
|
addSubview(topicView)
|
|
|
|
|
|
+ // 视频内容
|
|
|
+ addSubview(contentScrollView)
|
|
|
+ contentScrollView.addSubview(contentLabel)
|
|
|
+
|
|
|
+ // 视频标题
|
|
|
+ addSubview(videoTitleLabel)
|
|
|
+
|
|
|
addSubview(personBackView)
|
|
|
personBackView.addSubview(avatarButton)
|
|
|
personBackView.addSubview(personLabel)
|
|
@@ -145,13 +151,8 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
rainbowBeanView.addSubview(beanIconImageView)
|
|
|
rainbowBeanView.addSubview(beanLabel)
|
|
|
|
|
|
- addSubview(videoTitleLabel)
|
|
|
-
|
|
|
-
|
|
|
addSubview(playStatusImageView)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private func setupLayouts() {
|
|
@@ -239,14 +240,31 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
make.height.equalTo(45)
|
|
|
}
|
|
|
|
|
|
+ // 视频内容
|
|
|
+ contentScrollView.snp.makeConstraints { (make) in
|
|
|
+ make.bottom.equalTo(topicView.snp_top)
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.height.equalTo(44)
|
|
|
+ }
|
|
|
+
|
|
|
+ contentLabel.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 视频标题
|
|
|
+ videoTitleLabel.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.height.equalTo(23)
|
|
|
+ make.bottom.equalTo(contentScrollView.snp_top).offset(-10)
|
|
|
+ }
|
|
|
|
|
|
// personView
|
|
|
personBackView.snp.makeConstraints { (make) in
|
|
|
make.left.equalTo(14)
|
|
|
make.height.equalTo(30)
|
|
|
-
|
|
|
- // FIXME:待调整底约束
|
|
|
- make.bottom.equalToSuperview().offset(-200)
|
|
|
+ make.bottom.equalTo(videoTitleLabel.snp_top).offset(-20)
|
|
|
}
|
|
|
avatarButton.snp.makeConstraints { (make) in
|
|
|
make.left.top.equalToSuperview()
|
|
@@ -269,9 +287,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
rainbowBeanView.snp.makeConstraints { (make) in
|
|
|
make.left.equalTo(14)
|
|
|
make.height.equalTo(24)
|
|
|
-
|
|
|
- // FIXME:待调整底约束
|
|
|
- make.bottom.equalToSuperview().offset(-250)
|
|
|
+ make.bottom.equalTo(personBackView.snp_top).offset(-10)
|
|
|
}
|
|
|
beanIconImageView.snp.makeConstraints { (make) in
|
|
|
make.left.equalTo(6)
|
|
@@ -284,16 +300,6 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
make.right.equalTo(-6)
|
|
|
}
|
|
|
|
|
|
- videoTitleLabel.snp.makeConstraints { (make) in
|
|
|
- make.left.equalTo(14)
|
|
|
- make.right.equalTo(-14)
|
|
|
-
|
|
|
- // FIXME:待调整底约束
|
|
|
- make.bottom.equalToSuperview().offset(-150)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//
|
|
|
playStatusImageView.snp.makeConstraints { (make) in
|
|
|
make.center.equalToSuperview()
|
|
@@ -303,13 +309,62 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
|
|
|
}
|
|
|
|
|
|
- // 视频播放View
|
|
|
+ func addSeeMoreButton(_ label: YYLabel, textStr: String?) {
|
|
|
+ label.attributedText = NSAttributedString(string: textStr ?? "", attributes: [
|
|
|
+ NSAttributedString.Key.font: kRegularFont14!
|
|
|
+ ])
|
|
|
+
|
|
|
+ let moreString = " 展开"
|
|
|
+ var text = NSMutableAttributedString(string: "... \(moreString)")
|
|
|
+ let expandRange = (text.string as NSString).range(of: moreString)
|
|
|
+
|
|
|
+ text.addAttribute(.foregroundColor, value: UIColor.blue, range: expandRange)
|
|
|
+ text.addAttribute(.foregroundColor, value: UIColor.darkText, range: NSRange(location: 0, length: expandRange.location))
|
|
|
+
|
|
|
+ //添加点击事件
|
|
|
+ let hi = YYTextHighlight()
|
|
|
+ text.yy_setTextHighlight(hi, range: (text.string as NSString).range(of: moreString))
|
|
|
+ hi.tapAction = {
|
|
|
+ [weak self] (containerView, text, range, rect) in
|
|
|
+ //点击展开
|
|
|
+ self?.setTextFrame(true)
|
|
|
+ }
|
|
|
+
|
|
|
+ text.yy_font = kRegularFont14
|
|
|
+
|
|
|
+ let seeMore = YYLabel()
|
|
|
+ seeMore.attributedText = text
|
|
|
+ seeMore.sizeToFit()
|
|
|
+
|
|
|
+ let truncationToken = NSAttributedString.yy_attachmentString(withContent: seeMore, contentMode: UIView.ContentMode.center, attachmentSize: seeMore.frame.size, alignTo: text.yy_font!, alignment: YYTextVerticalAlignment.top)
|
|
|
+
|
|
|
+ label.truncationToken = truncationToken
|
|
|
+ }
|
|
|
+
|
|
|
+ func setTextFrame(_ isExpand: Bool) {
|
|
|
+ if isExpand {
|
|
|
+ expandString()
|
|
|
+ contentScrollView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 200)
|
|
|
+ contentLabel.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 200)
|
|
|
+ } else {
|
|
|
+ contentScrollView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 30)
|
|
|
+ contentLabel.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width - 40, height: 30)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func expandString() {
|
|
|
+ let attri = contentLabel.attributedText as? NSMutableAttributedString
|
|
|
+ contentLabel.attributedText = attri
|
|
|
+ }
|
|
|
+
|
|
|
+ // MARK: 视频播放View
|
|
|
private lazy var videoPlayView: CommunityVideoPlayView = {
|
|
|
let videoPlayView = CommunityVideoPlayView()
|
|
|
videoPlayView.isUserInteractionEnabled = true
|
|
|
return videoPlayView
|
|
|
}()
|
|
|
|
|
|
+ // MARK: 顶部导航View
|
|
|
private lazy var navBackView: UIView = {
|
|
|
let navBackView = UIView()
|
|
|
navBackView.backgroundColor = UIColor.clear
|
|
@@ -352,6 +407,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
return shareBtnLeft
|
|
|
}()
|
|
|
|
|
|
+ // MARK: 底部View
|
|
|
private lazy var bottomCommentView: UIView = {
|
|
|
let bottomCommentView = UIView()
|
|
|
bottomCommentView.backgroundColor = UIColor.clear
|
|
@@ -436,11 +492,40 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
return textBtn
|
|
|
}()
|
|
|
|
|
|
+ // MARK: 话题View
|
|
|
private lazy var topicView: CommunityVideoTopicView = {
|
|
|
let topicView = CommunityVideoTopicView()
|
|
|
return topicView
|
|
|
}()
|
|
|
|
|
|
+ // MARK: 视频内容content
|
|
|
+ private lazy var contentScrollView :UIScrollView = {
|
|
|
+ let contentScrollView = UIScrollView()
|
|
|
+ contentScrollView.bounces = false
|
|
|
+ // 设置初始contentSize
|
|
|
+ contentScrollView.contentSize = CGSize.init(width: kScreenWidth-28.0, height: 44.0)
|
|
|
+ contentScrollView.showsHorizontalScrollIndicator = false
|
|
|
+ contentScrollView.showsVerticalScrollIndicator = false
|
|
|
+ return contentScrollView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var contentLabel: YYLabel = {
|
|
|
+ let contentLabel = YYLabel()
|
|
|
+ contentLabel.numberOfLines = 0;
|
|
|
+ contentLabel.textColor = kffffffColor
|
|
|
+// contentLabel.font = kRegularFont15
|
|
|
+ return contentLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ // MARK: 视频Title
|
|
|
+ private lazy var videoTitleLabel: UILabel = {
|
|
|
+ let videoTitleLabel = UILabel()
|
|
|
+ videoTitleLabel.textColor = kffffffColor
|
|
|
+ videoTitleLabel.font = kMediumFont16
|
|
|
+ return videoTitleLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ // MARK: 个人信息View
|
|
|
private lazy var personBackView: UIView = {
|
|
|
let personBackView = UIView()
|
|
|
return personBackView
|
|
@@ -482,6 +567,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
return followButton
|
|
|
}()
|
|
|
|
|
|
+ // MARK: 彩虹豆View
|
|
|
private lazy var rainbowBeanView: UIView = {
|
|
|
let rainbowBeanView = UIView()
|
|
|
rainbowBeanView.backgroundColor = kRGBAColor(r: 0/255.0, g: 0/255.0, b: 0/255.0, a: 0.3)
|
|
@@ -503,14 +589,6 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
return beanLabel
|
|
|
}()
|
|
|
|
|
|
- private lazy var videoTitleLabel: UILabel = {
|
|
|
- let videoTitleLabel = UILabel()
|
|
|
- videoTitleLabel.textColor = kffffffColor
|
|
|
- videoTitleLabel.font = kMediumFont16
|
|
|
- return videoTitleLabel
|
|
|
- }()
|
|
|
-
|
|
|
-
|
|
|
// 播放暂停icon
|
|
|
private lazy var playStatusImageView: UIImageView = {
|
|
|
let playStatusImageView = UIImageView()
|