Closed zaeem-khatib closed 6 years ago
@zaeem-khatib
Call this method once on viewDidAppear once your tab bar was loaded.
func applyCornerRadiusToCenter(){
let sv: UIStackView? = (tabBar?. buttonsContainer.subviews[0] as? UIStackView)
if let sv = sv {
let centerIndex: Int = Int(sv.arrangedSubviews.count / 2) + 1
let centerView = sv.arrangedSubviews[centerIndex]
centerView.layer.cornerRadius = 5.0
centerView.layer.masksToBounds = true
}
}
Note that I have wrote this code blindly without testing so I don't know if it actaully works. Also make sure that the center button is highlighted.
@Minitour it does work. Thanks a lot for this. Also, could you please tell me if I wanted to add some leading and trailing margins to the stack view, how would that be done? At present it is having no margin from superview.
@Minitour if you can give a quick solution, it would be much appreciated.
@zaeem-khatib There is no way to do that without modifying the source code.
You will need to modify this function: https://github.com/Minitour/AZTabBarController/blob/master/Sources/AZTabBarController.swift#L1107
in which you can add constants to the constraints that are being added on the top,bottom,left,right.
Can we give corner radius to the selected tab bar item background? Similar to the attached screenshot. Any help would be much appreciated.