I have my xib set up and the screen now looks like this :

I have my cell.swift like this :
@IBOutlet weak var ivTabIcon: UIImageView!
@IBOutlet weak var lblTitle: UILabel!
@IBOutlet weak var viewBadge: UIView!
@IBOutlet weak var lblBadge: UILabel!
And I configure the title and icon like this in my parent view controller :
override func configure(cell: TabImageCellCollectionViewCell, for indicatorInfo: IndicatorInfo) {
cell.ivTabIcon.image = indicatorInfo.image
cell.lblTitle.text = indicatorInfo.title
}
But however this is useless because this is a one time configure, I would like to change the badge number after pulling some info from api. Which must happen outside of this configure function.
How do I access the badge property?
Thanks
Hi, @junweimah , i have did the same thing to access and update the badge,Its works, i have made the following function to do that.
func updateBadge(){
if let cell = buttonBarView.cellForItem(at: IndexPath(item: 1, section: 0)) as? FriendCollectionViewCell{
cell.badge.isHidden = self.totalFriendRequest == 0 ? true : false
cell.badgeCounter.text = self.totalFriendRequest.description
}
}
Please let me know if you are not clear yet.
Hi @kevadiyaVishal , It's working.
This post was very helpful for me.
Thanks!
Most helpful comment
Hi, @junweimah , i have did the same thing to access and update the badge,Its works, i have made the following function to do that.
Note: In my case i need to update only second cell of Bar, that is why i have tried to get the IndexPath(item: 1, section: 0)
Please let me know if you are not clear yet.