iphoneuibarbuttonitemstyle

How to set the button created in the navigation bar as custom in iphone?


I am new to iphone development.I have created a UIBarButtonItem on the navigation bar.I want to set the proper to custom. There is no property as custom for "style:" attribute.Please help me out.Thanks.

leftbutton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"LEFT.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftbutton)];
self.navigationItem.leftBarButtonItem = leftbutton;
[self.navigationItem]
[leftbutton release];

Solution

  • If you just want to display a .png file inside the usual button frame from Apple, then your code is ok. If your png file is not displaying, just check if it's valid.

    If you want to make your own button, you can use -(id)initWithCustomView:(UIView *)customView

    Check this post for an interesting sample code : Custom Bar Button Sample Code