2016-10-04 28 views
3

刪除頂線在iOS上10這個代碼不以去除的TabBar影線的工作:從的TabBar

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

有人知道,我必須做什麼要刪除嗎?

iOS 9.3用這兩條線刪除,但iOS 10忽略setShadowImage命令。

+0

你能告訴我圖形? –

+0

shadowImage文檔的最後一行說如果backgroundImage爲零,則會忽略shadowImage並應用默認陰影。所以請嘗試刪除setBackgroundImage以查看會發生什麼。 – iCyberPaul

+0

問題是,我需要將圖像設置爲tabBar背景... – Camacho

回答

11

剛剛嘗試吼叫代碼iOS的10: -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 
    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"fondoTabBar"]]; 
    [UITabBar appearance].layer.borderWidth = 0.0f; 
    [UITabBar appearance].clipsToBounds = true; 
    return YES; 
} 

斯威夫特3.X

UITabBar.appearance().layer.borderWidth = 0.0 
UITabBar.appearance().clipsToBounds = true 
+0

此代碼是我使用,直到iOs 10。此代碼適用於以前的iOs 10設備,但在iOs 10上不起作用。 – Camacho

+0

你可以試試這個演示它的iOS 10的工作: - https://www.dropbox.com/sh/g4cpq282b7adyg0/AADk3jBHshvsQ-FNIWwzuOOZa?dl=0 –

+0

感謝您的示例代碼。此代碼適用於iOs 10,但我需要更改tabBar背景,當我更改背景時顯示該行。這個代碼是相同的,只有我添加了一個背景圖像,你可以看到陰影圖像顯示在iOs 10上,在iOs 9.3上正常工作並且線條被隱藏。 https://1drv.ms/u/s!AlMk_BUOGnOImYtdCSCp6f1MGOu_AQ – Camacho

0

對於iOS 10改變的TabBar風格,黑色的伎倆

self.tabBarController.tabBar.shadowImage = UIImage() 
self.tabBarController.tabBar.barStyle = .Black 
0

我有同樣的問題lem in ios 10.我修正了這個問題,只是改變了UITabBar的高度(默認是49)。檢查一下here如何改變高度。

0

你應該實現在同一時間以下兩種方法:

[[UITabBar appearance] setShadowImage:[UIImage new]]; 
[[UITabBar appearance] setBackgroundImage:[UIImage new]]; 
0

如果你創建自己的UITabBarController的子類,你可以在viewDidLoad中設置 值這樣

斯威夫特3

override func viewDidLoad() { 
     super.viewDidLoad() 
     self.tabBar.layer.borderWidth = 0 
     self.tabBar.clipsToBounds = true 
} 
0

這是一個tabbar的陰影圖像(屬性)。嘗試以下解決方案並參閱。

試試這個, **的Objective-C **

//Remove shadow image by assigning nil value. 
[[UITabBar appearance] setShadowImage: nil]; 

// or 

// Assing UIImage instance without image reference 
[[UITabBar appearance] setShadowImage: [[UIImage alloc] init]]; 

** **雨燕

//Remove shadow image by assigning nil value. 
UITabBar.appearance().shadowImage = nil 

// or 

// Assing UIImage instance without image reference 
UITabBar.appearance().shadowImage = UIImage() 


這裏是shadowImage蘋果方針。

@available(iOS 6.0, *) 
open var shadowImage: UIImage? 

默認值是零。非零時,自定義陰影圖像顯示,而不是 默認陰影圖像。要顯示自定義陰影,還必須使用-setBackgroundImage設置自定義背景圖像:(如果使用 默認背景圖像,則會使用默認陰影圖像 )。

1

就在2號線消除了背線

tabBar.shadowImage = UIImage() 
tabBar.backgroundImage = UIImage()