0

iOS 7.0.
I need to make your design UITabBar. The picture (this link) shows how it looks now and how it should look. The difference is that:
1) The images on the buttons of some dirty color, and should be white
2) The selected item is highlighted in a little darker background color. Now he does not highlighted at all.

Here's how I define design in AppDelegate.m in application:didFinishLaunchingWithOptions

    // Background image for TabBar
    UIImage *backgroundDownImage = [UIImage imageNamed:@"background_320_49.png"];
    // Mode UIImageResizingModeStretch
    backgroundDownImage = [backgroundDownImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch];
    // Set background image for all UITabBar in application
    [[UITabBar appearance] setBackgroundImage:backgroundDownImage];
    // White color for TabBar buttons
    [[UITabBar appearance] setTintColor:[UIColor whiteColor]];

    // Special font for all UITabBarItem
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Xnjslkpqqovrwqxfnmropbgqtzp" size:0], UITextAttributeFont, nil] forState:UIControlStateNormal];

I tried the 4 variants:


1) In the method - (id)initWithNibName old code setFinishedSelectedImage + withFinishedUnselectedImage
2) In the method - (id)initWithNibName new code setImage + SetSelectedImage
3) In the method - (void)viewDidLoad old code
4) In the method - (void)viewDidLoad new code

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Variant 1
    [self.tabBarItem setImage:[[UIImage imageNamed:@"Live.png"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];
    [self.tabBarItem setSelectedImage:[[UIImage imageNamed:@"Live.png"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];

    // Variant 2
    //[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"Live.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"Live.png"]];

    [CommonUse showLiveVideoFromController:self];
}

In all cases, icons will be displayed. Method initWithNibName (options 1 and 2) no action at all on the color icon has not. Method viewDidLoad work both old and new code - but in a strange way. When you first run the application, only the first icon is white, and all the other gray. If you click on any other icon and then go back to the first, this icon becomes white (but only a picture! Text is still gray). It turns out that the color of icons affects only method viewDidLoad but not entirely - something else is missing.

Maybe draw two sets of icons for Selected and NoSelected. That was in the icon and image and text description as graphic. But still remain two points: 1) When you first start the application, all the icons will be gray, and only the first will be white. 2) When you change the width of the screen, do not disperse if the buttons.

MinistrBob
  • 21
  • 6

2 Answers2

0
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"partners_hover.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"partners_small.png"]];
    }
    return self;
}
user3663584
  • 100
  • 6
  • It works, but not as much as I want. Read my question and see my picture - I want to icons were white, not gray. And yet, the documentation says that these methods are depricated in iOS7. Need to use [tabBarItem setImage: imageWithRenderingMode:] and [tabBarItem setSelectedImage: imageWithRenderingMode:] – MinistrBob Jun 24 '14 at 08:49
0

To change a color for unselected items (icons) you can use UITabBar property unselectedItemTintColor

[UITabBar appearance].unselectedItemTintColor = [UIColor anyColor];
Syngmaster
  • 415
  • 8
  • 13