Reputation: 2547
I implemented tab bar with custom icon size.i find many solution from stack-overflow but i didn't getting any perfect solution for this issue.
Issue : when i click tabbar item again and again it's size double every time. and after click other tab it's size is same as orignal size.
See this Link For Issue : Screen Recording
My Code :
import UIKit
class customTabBar: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let tabHome2 = self.tabBar.items![2]
tabHome2.image = UIImage(named: "ic_pick")?.withRenderingMode(.alwaysOriginal)
tabHome2.selectedImage = UIImage(named: "ic_pick")?.withRenderingMode(.alwaysOriginal)
tabHome2.imageInsets = UIEdgeInsets(top: -40, left: -10, bottom: 0, right: -10)
}
}
My Design Requirement :
Thanks In Advance.
Upvotes: 2
Views: 991
Reputation: 741
Your image insets are not balanced. Try:
tabHome2.imageInsets = UIEdgeInsets(top: -20, left: -10, bottom: 20, right: 10)
Upvotes: 0
Reputation: 534
Set Icons in assets. If you are using circular icons for tab bar item you should create following sizes for portrait mode:
@1x : about 25 x 25 (max: 48 x 32)
@2x : about 50 x 50 (max: 96 x 64)
@3x : about 75 x 75 (max: 144 x 96)
Also you can refer this : custom-icons
Set image inset from the property of Tabbar item. Image
Upvotes: 1