Commit 032bc955 authored by Steven杜宇's avatar Steven杜宇

// 我的好友

parent 276b2a29
......@@ -78,24 +78,28 @@ class YHCommunityViewController: YHBaseViewController {
var unreadCount:Int = 0 {
didSet {
self.unreadLabel.isHidden = (self.unreadCount <= 0)
if 0 < self.unreadCount && self.unreadCount < 100 {
self.unreadLabel.text = "\(self.unreadCount)"
} else if self.unreadCount >= 100 {
self.unreadLabel.text = "99+"
}
var width = unreadHeight
var leftMargin = -8
if 10 <= self.unreadCount && self.unreadCount < 100 {
width = 22.0
} else if self.unreadCount >= 100 {
width = 30.0
leftMargin = -14
}
self.unreadLabel.snp.updateConstraints { make in
make.width.equalTo(width)
make.left.equalTo(self.friendsBtn.snp.right).offset(leftMargin)
}
self.updateUnreadCount(self.unreadCount)
}
}
func updateUnreadCount(_ count : Int) {
self.unreadLabel.isHidden = (count <= 0)
if 0 < count && count < 100 {
self.unreadLabel.text = "\(count)"
} else if count >= 100 {
self.unreadLabel.text = "99+"
}
var width = unreadHeight
var leftMargin = -8
if 10 <= count && count < 100 {
width = 22.0
} else if count >= 100 {
width = 30.0
leftMargin = -14
}
self.unreadLabel.snp.updateConstraints { make in
make.width.equalTo(width)
make.left.equalTo(self.friendsBtn.snp.right).offset(leftMargin)
}
}
......@@ -206,8 +210,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate {
if segmentedView.selectedIndex == 0 {
bgImgV.isHidden = false
friendsBtn.isHidden = false
let count = self.unreadCount
self.unreadCount = count
self.updateUnreadCount(self.unreadCount)
segmentedDataSource.titleNormalColor = UIColor(hex: 0xFFFFFF, alpha: 0.6)
segmentedDataSource.titleSelectedColor = .white
let indicator = JXSegmentedIndicatorLineView()
......@@ -217,7 +220,7 @@ extension YHCommunityViewController: JXSegmentedViewDelegate {
} else {
bgImgV.isHidden = true
friendsBtn.isHidden = true
self.unreadCount = 0
self.updateUnreadCount(0)
segmentedDataSource.titleNormalColor = UIColor(hex: 0x94a3b8)
segmentedDataSource.titleSelectedColor = UIColor.mainTextColor
let indicator = JXSegmentedIndicatorLineView()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment