2012-01-17 10 views
3

iOS 5で、UIの外観があり、簡単にグラデーションを削除できますか?iOS 5でUITabbaritemのグラデーション/ドロップシャドウを削除する方法

私はこれをカスタマイズしてタブバーをカスタマイズしましたが、グラデーションを削除するにはどうすればよいですか?画像を取得してそのまま使用するには、2枚の処理画像を選択/非選択画像を構築または取るために、そのアルファチャンネル(不透明度)を使用するか

-(void)UIAppearances 
{ 
    //set the background of tab bar 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navbar_bgrd.png"]]; 

    if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { 
     //iOS 5 
     //[self.tabBarController.tabBar insertSubview:imageView atIndex:1]; 

     [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_bgrd.png"]]; 
     [[UITabBar appearance] setSelectionIndicatorImage: 
     [UIImage imageNamed:@"navbaractive.png"]]; 


     [[UITabBarItem appearance] setTitleTextAttributes: 
     [NSDictionary dictionaryWithObjectsAndKeys: 
      [UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1.0], UITextAttributeTextColor, 
      [UIColor clearColor], UITextAttributeTextShadowColor, 
      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
      nil] forState:UIControlStateNormal]; 

     [[UITabBarItem appearance] setTitleTextAttributes: 
     [NSDictionary dictionaryWithObjectsAndKeys: 
      [UIColor whiteColor], UITextAttributeTextColor, 
      [UIColor clearColor], UITextAttributeTextShadowColor, 
      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
      nil] forState:UIControlStateSelected]; 


     //nav bar 
     [[UINavigationBar appearance] setTitleTextAttributes: 
     [NSDictionary dictionaryWithObjectsAndKeys: 
      [UIFont fontWithName:@"Rokkitt" size:28.0], 
      UITextAttributeFont, 
      nil]]; 
    } 
    else { 
     //iOS 4.whatever and below 
     [self.tabBarController.tabBar insertSubview:imageView atIndex:0]; 

    } 

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO]; 

} 

答えて

4

UITabBarを読み取る

おかげ。

あなたはUITabBarItemに自分で画像を提供する必要があります。setFinishedSelectedImage:withFinishedUnselectedImage:です。 UITabBarの外観プロパティーであるselectedImageTintColorでグラデーションの色を変更するだけでなく、画像に適用される処理に影響する他の方法はありません。

+0

uはios 5以降しか使用できません。 – lesyk

+0

@lesyk:正解。私はそれも言いましたが、なぜ私はそれを言及しなかったのですかというドキュメントをリンクしました。私はそれを調べていないので、iOSの前にこれをどのように達成するのか分かりません。多分UITabBarをサブクラス化するかもしれません。 – Jesper

関連する問題