2012/08/24

更改UITabBarItem選擇到的背景

做Project時稍微查詢了一下,UITabBarItem的icon大小為30*30
(來源:stackoverflow: What is the max size of a UITabBarItem image?)

於是就來著手處理UITabBarItem的東西,好奇心驅使之下,去查了如何改變selected item的背景!(iOS SDK真的有夠強大,很整齊又很有自由度!)

於是Google到了這篇
(來源:stackoverflow: How to change Background color of UITabbar selected tab color to blue?)
真的還頗容易的:
首先他先回答了如何更改UITabBar的背景顏色,用tintColor:去實現
myTabBarController.tabBar.tintColor = [UIColor blueColor];


再來就是修改選中item的背景,設定selectionIndicatorImage這個變數,就可以達到自己想要的效果了!
myTabBarController.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"myImage.png"];

沒有留言:

張貼留言