Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can achieve that and more using the new appearance API introduced in iOS 5.</p> <p>Basically you set the appearance for your UI once and it gets reflected in the whole program.</p> <p>Here is an example for the <code>UIBarButtonItem</code>:</p> <pre><code>// You can also use stretchable images UIImage *image = [[UIImage imageNamed:@"myCoolBarButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)]; [[UIBarButtonItem appearance] setBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; </code></pre> <p>If you cannot use iOS 5, then you have to build those programmatically like this:</p> <pre><code>// Create a custom button with an image UIImage *image = [UIImage imageNamed:@"myCoolBarButton.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:image forState:UIControlStateNormal]; button.frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height); // Create a custom UIBarButtonItem with the button UIBarButtonItem aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton]; </code></pre> <p>Anyway, here are a few links with good tutorials on the appearance subject</p> <p><a href="http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5">User Interface Customization in iOS 5</a></p> <p><a href="http://mobileorchard.com/how-to-make-your-app-stand-out-with-the-new-ios-5-appearance-api/">How To Make Your App Stand Out With The New iOS 5 Appearance API</a></p> <p>EDIT: Just for clarification, it is much easier to do with custom images than playing around with colors, gradients and transparency.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload