I've manually added a Tab Bar Controller from Main file (XCode 14.1). I take it this is the Main storyboard
Both Item Scenes has their own controller class (custom class).
In either class, I want to change the item image and title. For this question, the image. Inside one of the corresponding scene class (ProfileViewController):
override func viewDidLoad() {
super.viewDidLoad()
// Does nothing (both)
self.tabBarController?.tabBar.items![1].image = UIImage(named: "square.and.arrow.up.circle")
self.tabBarItem.image = UIImage(named: "square.and.arrow.up.circle")
}
I would like to change the image programatically as for one of the tabs, I get the image externally.
CodePudding user response:
You are creating the image incorrectly. To use one of the SF Symbols you need to use:
UIImage(systemName: "square.and.arrow.up.circle")
Using UImage(named:)
tries to load an image from your resource bundle or image assets.