0

I have been customising tab bar with rounded button in center and set corner radius curve as well, I have set in storyboard as below,

enter image description here

I have rendered image as original, but my issue is when I run in simulator, the upper half of rounded circle is missing as shown in image,

enter image description here

I have set class for UITabBar,

class ProminentTabBar: UITabBar {
    var prominentButtonCallback: (()->())?
    
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        guard let items = items, items.count>0 else {
            return super.hitTest(point, with: event)
        }
        
        let middleItem = items[items.count/2]
        let middleExtra = middleItem.imageInsets.top
        let middleWidth = bounds.width/CGFloat(items.count)
        let middleRect = CGRect(x: (bounds.width-middleWidth)/2, y: middleExtra, width: middleWidth, height: abs(middleExtra))
        if middleRect.contains(point) {
            prominentButtonCallback?()
            return nil
        }
        return super.hitTest(point, with: event)
    }
}

and tabbarcontroller added below lines as well,

override func viewDidLoad() {
    super.viewDidLoad()
    
    let prominentTabBar = self.tabBar as! ProminentTabBar
    prominentTabBar.prominentButtonCallback = prominentTabTaped
}

func prominentTabTaped() {
    selectedIndex = (tabBar.items?.count ?? 0)/2
}

This source was from stack overflow ticket:- How do we create a bigger center UITabBar Item

Does anyone have solution for this>?

Aleesha
  • 124
  • 2
  • 21

1 Answers1

0

make

tabbar.clipsToBounds = false

You can change it via code or in StoryBoard

Keep coding........ :)

Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66