2013-08-16 70 views
2

我在我的應用程序中使用UITabbarController,並且我將框架設置爲它,以便tabbar顯示在中心。我是如此改變tabbar的顏色和形象,但我想刪除它不清楚的小邊緣我怎麼能清除那個顏色變成白色。自定義tabbar和tabbar項目

代碼:[[UITabBar appearance] setShadowImage : [UIImage imageNamed:@"white.png"]]; enter image description here

回答

3

另一種選擇是,加

#import <QuartzCore/QuartzCore.h> 

框架和使用

self.tabBarController.tabBar.layer.borderWidth = 0.50; 
self.tabBarController.tabBar.layer.borderColor = self.tabBarController.tabBar.tintColor.CGColor; 
+0

我可以刪除該邊框:) – Rushabh

+0

任何我無法用故事板中的用戶定義的運行屬性修改這些屬性的原因? – klefevre

+0

@klefevre,因爲運行時屬性使用UIColor,而CALayer使用核心圖形或CGColors。 如果需要,您可以添加一個CALayer + RuntimeAttributes來轉換它。做一個看起來像這樣的方法: - (void)setShadowSBColor:(UIColor *)shadowUIColor self.shadowColor = shadowUIColor.CGColor; } 然後調用do layer.shadowSBColor作爲運行時屬性。覆蓋你需要的任何其他方法 – gadu

0
[[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"transparentImage.png"]]; 

與透明圖像試試這個。

[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]]; 
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]]; 

這些都是負責。嘗試第二種方法,因爲第一種方法不適合你。

+0

感謝您的回覆。我已經做到了,但對我來說沒有運氣。 – Nirmalsinh

+0

然後,設置'tabBar.clipsToBounds = YES;'屬性。 @Napster – Ashwani

+0

self.tabBarController.tabBar.clipsToBounds = YES;它不工作:) – iPatel

1

添加clipsToBounds並設置爲YES。

clipsToBounds