|
|
|
@ -31,43 +31,44 @@ class CommentCountButton: UIControl {
|
|
|
|
|
|
|
|
|
|
var count: Int? {
|
|
|
|
|
didSet {
|
|
|
|
|
// self.commentImageView.snp.removeConstraints()
|
|
|
|
|
// self.commentCountLabel.snp.removeConstraints()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let count = count, count > 0 {
|
|
|
|
|
commentCountLabel.isHidden = false
|
|
|
|
|
commentCountLabel.text = count.commentDigital(aimCount: 999)
|
|
|
|
|
} else {
|
|
|
|
|
commentCountLabel.isHidden = true
|
|
|
|
|
commentCountLabel.text = " "
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let count = count, count > 0 {
|
|
|
|
|
commentCountLabel.snp.remakeConstraints { make in
|
|
|
|
|
make.right.equalTo(self).offset(-4)
|
|
|
|
|
make.top.equalTo(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commentImageView.snp.remakeConstraints { make in
|
|
|
|
|
make.left.equalTo(self)
|
|
|
|
|
make.right.equalTo(commentCountLabel.snp.left).offset(0)
|
|
|
|
|
make.top.equalTo(self)
|
|
|
|
|
make.bottom.equalTo(self)
|
|
|
|
|
make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// commentCountLabel.snp.makeConstraints { make in
|
|
|
|
|
// make.right.equalTo(self)
|
|
|
|
|
// make.top.equalTo(self)
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// commentImageView.snp.makeConstraints { make in
|
|
|
|
|
// make.left.equalTo(self)
|
|
|
|
|
// make.right.equalTo(commentCountLabel.snp.left).offset(0)
|
|
|
|
|
// make.top.equalTo(self)
|
|
|
|
|
// make.bottom.equalTo(self)
|
|
|
|
|
// make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
commentCountLabel.isHidden = true
|
|
|
|
|
|
|
|
|
|
// commentImageView.snp.makeConstraints { make in
|
|
|
|
|
// make.left.equalTo(self)
|
|
|
|
|
// make.top.equalTo(self)
|
|
|
|
|
// make.bottom.equalTo(self)
|
|
|
|
|
// make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
// make.right.equalTo(self)
|
|
|
|
|
// }
|
|
|
|
|
commentCountLabel.snp.removeConstraints()
|
|
|
|
|
commentImageView.snp.removeConstraints()
|
|
|
|
|
|
|
|
|
|
commentImageView.snp.remakeConstraints { make in
|
|
|
|
|
make.left.equalTo(self)
|
|
|
|
|
make.top.equalTo(self)
|
|
|
|
|
make.bottom.equalTo(self)
|
|
|
|
|
make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
make.right.equalTo(self)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.setNeedsLayout()
|
|
|
|
|
self.layoutIfNeeded()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -100,37 +101,15 @@ class CommentCountButton: UIControl {
|
|
|
|
|
|
|
|
|
|
override func layoutSubviews() {
|
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let count = count, count > 0 {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commentCountLabel.snp.makeConstraints { make in
|
|
|
|
|
make.right.equalTo(self).offset(-4)
|
|
|
|
|
make.top.equalTo(self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commentImageView.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(self)
|
|
|
|
|
make.right.equalTo(commentCountLabel.snp.left).offset(0)
|
|
|
|
|
make.top.equalTo(self)
|
|
|
|
|
make.bottom.equalTo(self)
|
|
|
|
|
make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
commentImageView.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(self)
|
|
|
|
|
make.top.equalTo(self)
|
|
|
|
|
make.bottom.equalTo(self)
|
|
|
|
|
make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
make.right.equalTo(self)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// commentImageView.snp.makeConstraints { make in
|
|
|
|
|
// make.left.equalTo(self)
|
|
|
|
|
// make.top.equalTo(self)
|
|
|
|
|
// make.bottom.equalTo(self)
|
|
|
|
|
// make.size.equalTo(CGSize.init(width: 24, height: 24))
|
|
|
|
|
// make.right.equalTo(self)
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|