Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone SDK: UIBarButtonItem is not displaying border
    text
    copied!<p>I have a UIToolbar which I am trying to put some custom UIBarButtonItems on. However, when I use the code below, the button shows up with <strong>NO</strong> border.</p> <pre><code> UIImage *cameraRollButtonImage = [UIImage imageNamed:@"Flash.png"]; UIButton *cameraRollButton = [UIButton buttonWithType:UIButtonTypeCustom]; [cameraRollButton setImage:cameraRollButtonImage forState:UIControlStateNormal]; cameraRollButton.frame = CGRectMake(0.0, 0.0, cameraRollButtonImage.size.width, cameraRollButtonImage.size.height); // Initialize the UIBarButtonItem cameraRollButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cameraRollButton]; [cameraRollButtonItem setStyle:UIBarButtonItemStyleBordered]; //Add the Buttons to the toolbar NSArray *toolbarItems = [NSArray arrayWithObject:cameraRollButtonItem]; [self.cameraTabBar setItems:toolbarItems]; </code></pre> <p>This displays the button just fine, however, there is NO button border (like standard the <code>UIBarButtonItem</code>). So the line <code>[cameraRollButtonItem setStyle:UIBarButtonItemStyleBordered];</code> doesn't seem to do anything.</p> <p>Does anyone have any experience with this?</p> <p>I would like to be able to eventually rotate the image in the button when the device orientation is changed (keeping the toolbar static), so simply adding an image to the <code>UIBarButtonItem</code> doesn't work; I need to get this to work with by using the <code>customView</code> property.</p> <p>Many thanks! Brett</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