想修改內建 tab icon 的文字,可以嗎 ?

iOS 的 tab 提供了一系列內建的樣式給我們選擇,一些常用的功能,Apple 都已貼心幫我們製作好,比方 Favorites 的星星圖案, Search 的放大鏡圖案等。

只要從 Tab Bar Item 的 System Item 欄位,即可選擇這些內建的樣式。

但是,一旦你採用了內建的樣式,文字將再也不能修改,就算你是上帝也改變不了 !

如果你希望 tab icon 的圖案長得像內建的圖案,但是換個名字,比方顯示星星圖案,文字寫帥到分手,唯一的方法就是加入自製的圖案,不能再靠內建。

現在手術那麼發達,要長得像劉德華都不是問題,更何況是 tab icon。你可從以下連結,抓到 gmawji 大大精心整理的 iOS 10 內建 icon 圖庫。

下載後解壓縮,在資料夾 @2x > com.apple.uikit.Artwork 下,UITabBar 開頭的那些檔案,即是 tab 的 icon。比方星星圖案是 UITabBarFavoritesTemplate@2x.png。

有了圖案後,到時只要將圖片加到 Assets.xcassets,然後設定 Tab Bar Item 的 Image 欄位,即可顯示圖案星星,文字帥到分手的 tab。

彼得潘的 Swift iOS App 開發問題解答集

彼得潘和學生們在開發 iOS App 路上曾經解決的問題集

)

彼得潘的 iOS App Neverland

Written by

彼得潘的 Swift 程式設計入門,App程式設計入門作者,彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,http://apppeterpan.strikingly.com

彼得潘的 Swift iOS App 開發問題解答集

彼得潘和學生們在開發 iOS App 路上曾經解決的問題集

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade