user1244311
user1244311

Reputation: 301

Customization of UITabBar

I am using UITabBar with 3 tab bar items. I want to customize center tab item. like raised tab bar button.

I know how to add UITabBarController and customizing that. But I want to customize UITabBar.

I want to add a customized button to tab bar as a center tab bar item, like this:

enter image description here

Upvotes: 1

Views: 1169

Answers (2)

Rahul Lalit
Rahul Lalit

Reputation: 416

check this http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/

UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
    [button setBackgroundImage:buttonImage forState:UIControlStateNormal];
    [button setBackgroundImage:highlightImage forState:UIControlStateHighlighted];

    CGFloat heightDifference = buttonImage.size.height - self.tabBar.frame.size.height;
    if (heightDifference < 0)
      button.center = self.tabBar.center;
    else
    {
      CGPoint center = self.tabBar.center;
      center.y = center.y - heightDifference/2.0;
      button.center = center;
    }

    [self.view addSubview:button];

Upvotes: 1

Mert
Mert

Reputation: 6065

you can change

  backgroundImage  property
  selectedImageTintColor  property
  selectionIndicatorImage  property
  tintColor  property

of a uitabbar

maybe you can achive with a background image. If not then you have to write your own tabbar.

Upvotes: 0

Related Questions