I am trying to set a different image as selectedImage
, I found this script to put in AppDelegate:
var tabBarController = self.window!.rootViewController as UITabBarController
let tabItems = tabBarController.tabBar.items as [UITabBarItem]
tabItems[2].selectedImage = UIImage(named: "image.png")
But it does not work.
Am I missing something obvious or made a mistake?
You can try by adding this line instead of tabItems[2].selectedImage = UIImage(named: "image.png")
var selectedBG = UIImage(named:””)
UITabBar.appearance().selectionIndicatorImage = selectedBG
没关系,Xcode中的“选定图像”框现在可以使用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.