[英]IOS - tab bar item image modifications
從蘋果我們知道
默認情況下,實際的未選擇和選擇的圖像是根據源圖像中的alpha值自動創建的。 為防止系統變色,請為圖像提供UIImageRenderingModeAlwaysOriginal。
在這里看看。
更改標簽欄項目圖像和文本顏色iOS
我可以使用以下方法更改突出顯示和不突出顯示的圖像以及位置:
let profileNavController = UINavigationController(rootViewController: profileController)
let profileTabBarItem = UITabBarItem(title: nil, image: UIImage(named: "icon_tab_user")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal), selectedImage: UIImage(named: "icon_tab_user_highlighted"))
profileTabBarItem.imageInsets = UIEdgeInsetsMake(5.5, 0, -5.5, 0)
profileNavController.tabBarItem = profileTabBarItem
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.