2016-07-25 5 views
0

私はUITabbarのアプリケーションを持っていますが、Tabbarに画像を設定したいのですが、Tabbarに画像を設定できません。それは画像ではなく、色合いの色でイメージの形を取得します。イメージをそのままTabbarに設定できますか? 。iosの色調ではなくタブバーに画像を設定するには?

私はこのコードを試しましたが、イメージを設定できませんでした。

UITabBar *tabBar = self.tabBar; 

UITabBarItem *targetTabBarItem = [[tabbar items] objectAtIndex:0]; // whichever tab-item 
UIImage *selectedIcon = [UIImage imageNamed:@"name-of-selected-image.png"]; 
[targetTabBarItem setSelectedImage:selectedIcon]; 
+0

...それは – remyr3my

答えて

7

を試してみてください。この

enter image description here

OR

設定し、選択した色合いの色のようなあなたの画像を設定しますあなたのイメージ属性プロパティーRender AsOriginal Image。これを変更するには、資産をAttributes InspectorRender Asに設定して画像をOriginal Imageに設定します。

enter image description here

+0

おかげでたくさんの画像を追加 –

+0

...首尾よく動作しますが、画像の色合いの色が変化していない?属性インスペクタを通じて – kishor0011

+0

@ kishor0011はい、ランダードモードを元の画像に設定した後は、その画像で色合いを使用することはできません。 –

0

あなたのTabBarの項目を選択し、設定する必要があり、この

[[UITabBar appearance] setTintColor:[UIColor whiteColor]]; 

    [UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal]; 
    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"name-of-selected-image.png"]]; 
    [[UITabBar appearance]setSelectedItem:[[UITabBar appearance].items objectAtIndex:2]]; 
関連する問題