![](/img/trans.png)
[英]How can I change the color of the UITabBar top border by creating a UIImage programmatically?
[英]Change the default color of top border line of UItabbar
您好,任何人都可以幫助我,將不勝感激,我想知道您如何更改 UItab 欄頂部的默認灰色筆划的顏色,我還希望筆划為 2px。 我嘗試了各種編碼方法,將此代碼放在視圖控制器中:
self.tabBarController!.tabBar.layer.borderWidth = 0.50 self.tabBarController!.tabBar.layer.borderColor = UIColor.clearColor().CGColor
它在整個標簽欄周圍放置了一個筆划。 我想要一個 2px 的描邊,自定義 rgb 顏色:紅色:208,綠色:28,藍色:28
比如下圖:
可能的選項:
為 tabBar 使用(可拉伸的)背景圖像
不建議使用現有的 UI 元素,但您可以嘗試簡單地添加一個新的子視圖,其寬度與 Tab Bar 相同,高 2 像素,您想要作為背景的顏色,放置在 (0,0)
您可以使用UITabBar
的shadowImage
屬性!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.