Note that there are some explanatory texts on larger screens.

plurals
  1. POUIBarButtonItem with custom image and no border
    primarykey
    data
    text
    <p>I want to create a UIBarButtonItem with a custom image, but I don't want the border that iPhone adds, as my Image has a special border.</p> <p>It's the same as the back button but a forward button.</p> <p>This App is for an inHouse project, so I don't care if Apple reject or approves it or likes it :-)</p> <p>If I use the initWithCustomView:v property of the UIBarButtonItem, I can do it:</p> <pre><code>UIImage *image = [UIImage imageNamed:@"right.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage: [image stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateNormal]; [button setBackgroundImage: [[UIImage imageNamed: @"right_clicked.png"] stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateHighlighted]; button.frame= CGRectMake(0.0, 0.0, image.size.width, image.size.height); [button addTarget:self action:@selector(AcceptData) forControlEvents:UIControlEventTouchUpInside]; UIView *v=[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ]; [v addSubview:button]; UIBarButtonItem *forward = [[UIBarButtonItem alloc] initWithCustomView:v]; self.navigationItem.rightBarButtonItem= forward; [v release]; [image release]; </code></pre> <p>This works, but if I have to repeat this process in 10 views, this is not DRY.</p> <p>I suppose I have to subclass, but what ?</p> <ul> <li>NSView ?</li> <li>UIBarButtonItem ?</li> </ul> <p>thanks,</p> <p>regards,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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