• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to scale a TabBarItem Image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to scale a TabBarItem Image


  • Subject: How to scale a TabBarItem Image
  • From: ico <email@hidden>
  • Date: Wed, 26 Jan 2011 19:10:41 +0800

Hi All,

I want to add a UITabBar in my UIViewController, I don't want to use
UITabBarController because I need to push this view controller into a
navigation controller. Everything is fine except that my images for
UITabBarItem is not scale to fit the item size to be displayed properly. As
it should be as described in the UITabBarItem documentation:
*image*

The item’s image. If nil, an image is not displayed.

The images displayed on the tab bar are derived from this image. If this
image is too large to fit on the tab bar, it is scaled to fit. The size of
an tab bar image is typically 30 x 30 points. The alpha values in the source
image are used to create the unselected and selected images—opaque values
are ignored.

How to fix this problem?

Here are some codes:

UITabBar *myTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0.0,
barHeight, screenBounds.size.width, 50.0)];
myTabBar.opaque = YES;

UITabBarItem *barItem1 = [[UITabBarItem alloc] initWithTitle:@"title1"
image:[UIImage imageNamed:@"icon1.png"] tag:1];
UITabBarItem *barItem2 = [[UITabBarItem alloc] initWithTitle:@"title2"
image:[UIImage imageNamed:@"icon2.png"] tag:2];
UITabBarItem *barItem3 = [[UITabBarItem alloc] initWithTitle:@"title3"
image:[UIImage imageNamed:@"icon3.png"] tag:3];
UITabBarItem *barItem4 = [[UITabBarItem alloc] initWithTitle:@"title4"
image:[UIImage imageNamed:@"icon4.png"] tag:4];

NSArray *tbItems = [NSArray arrayWithObjects:barItem1, barItem2, barItem3,
barItem4, nil];
myTabBar.items = tbItems;

--
==========================
Life isn't about finding yourself.
Life is about creating yourself.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to scale a TabBarItem Image
      • From: Steve Christensen <email@hidden>
    • Re: How to scale a TabBarItem Image
      • From: glenn andreas <email@hidden>
  • Prev by Date: Re: Using NSWindow without NIB (XIB) file ?
  • Next by Date: Re: Image preview with UIWebView
  • Previous by thread: Re: Image preview with UIWebView
  • Next by thread: Re: How to scale a TabBarItem Image
  • Index(es):
    • Date
    • Thread