I would like to display a custom icon on the tab in the UITabBarController.
I think the way to customize the icon on this tab is to display the image cut out like a line drawing based on the Apple UITabBarController.
The only way to customize the background image was to change the background image based on Apple's regulated UITabBarController.
It seems that the size cannot be changed within the storyboard as well.
I would like to customize the size of the UITabBarController itself (or the icon itself) and change it to a colored image that I created myself and implement it. Is this something that can be implemented within Xcode?
xcode storyboard
I want UITabBarController to display custom icons on tabs
This approach is not correct.The approach is to the View Controller.
On the Storyboard, click the icon on the View Controller tab bar to see the Attributed Inspector shown below.
Set the System Item to ImCustom 」 and specify the Image as any image.The image does not have to be a "line drawing" and can be a bitmap image of 32 pixels or less on each side.
To specify an icon when you add a View Controller to a Tabbar Controller in a program.(This sample code should be written to any View Controller class.)
let thirdViewController=UIViewController()
thirdViewController.view.backgroundColor=UIColor.yellowColor() // Customize View Controller
thirdViewController.tabBarItem.image=UIImage(named: "third.png")// The filename is optional.
var viewcontrollers = self.tabBarController ?.viewControllers
viewcontrollers?append(thirdViewController)
self.tabBarController?.setViewControllers(viewcontrollers!, animated:true)
As you can see, the tab bar icon is set to a UIViewController, not a UITabBarController.
© 2024 OneMinuteCode. All rights reserved.