eggswift / ESTabBarController

:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie!
MIT License
5.17k stars 578 forks source link

Add border around badge #25

Closed dungi closed 7 years ago

dungi commented 7 years ago

Hello, can I add a 1px border around badge-Icon? I just found how to change color and change the number.

Would be helpful, thank you

eggswift commented 7 years ago

Hi, There r 2 ways to achieve:

  1. Custom item.contentView
  2. Set badgeLabel's border, example codes:
    static func customRemindStyle() -> UITabBarController {
    ...
    if let tabBarItem = v1.tabBarItem as? ESTabBarItem {
            tabBarItem.badgeValue = "New"
            tabBarItem.contentView!.badgeView.badgeLabel.layer.borderWidth = 2
        }
    ...
dungi commented 7 years ago

Thanks.

I think: tabBarItem.contentView!.badgeView.layer.borderWidth = 2 (+ Radius and color) would be better. Cause I want a border around the round background. Looks great now.