簡體   English   中英

Swift:更改標簽欄的圖像色調顏色?

[英]Swift: Change the image tint color of tab bar?

我以編程方式創建了 tabBarController 並且我想更改選項卡包含的圖像(而不是條)的色調顏色。 誰能告訴我如何在 Swift 中做到這一點?

在您的“應用程序:didFinishLaunchingWithOptions”中

(window?.rootViewController as! UITabBarController).tabBar.tintColor = UIColor.red

或使用外觀委托。

UITabBar.appearance().tintColor = UIColor.red

另一個很好的解決方案:

添加名為 "tintColor" 的運行時顏色屬性

它將改變圖像色調顏色以及標題色調顏色。

在此處輸入圖片說明

在此處輸入圖片說明

轉到 AppDelegate.swift 文件。 在“應用程序:didFinishLaunchingWithOptions”中寫:

UITabBar.appearance().unselectedItemTintColor = UIColor.red

以上所有答案都在這里,我正在分享使用故事板檢查器來實現這一目標

選擇您的標簽欄轉到檢查器並將圖像色調更改為相應的顏色以供參考附加圖像

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM