I want to set the images of tab bar items a bigger size. So I put this code in my TabBarViewController.viewDidLoad():
let titleTabrItems = ["Favourites","Calc","Time","Live","Shop"]
for (index,item) in (self.tabBar.items ?? []).enumerated() {
item.title = ""
let image = item.image?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
let selectedImage = item.selectedImage?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
item.image = image
if index < titleTabrItems.count {
item.title = titleTabrItems[index]
}
item.titlePositionAdjustment = UIOffsetMake(0, 10000)
item.selectedImage = selectedImage
item.imageInsets = UIEdgeInsets(top: 0, left: -10, bottom: -6, right: -10)
}
self.navigationController?.setNavigationBarHidden(true, animated: false)
but if I click twice or more times on one item, te image turns bigger and bigger. I guess I still not able to use the EdgeInsets properly. How can I fix the scaling issue and set a bigger size to the images? I created the image files according to Apple documentation (75px/3x, 50px/2x, 25px/1x).