Created
October 4, 2011 13:13
-
-
Save arnaudbos/1261613 to your computer and use it in GitHub Desktop.
Create a UIBarButtonItem with a red (or other image) background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://i.stack.imgur.com/P0xJO.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
[cancelButton setBackgroundImage:[UIImage imageNamed:@"delete.png"] forState:UIControlStateNormal]; | |
[cancelButton setTitle:@"Annuler" forState:UIControlStateNormal]; | |
cancelButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f]; | |
[cancelButton.layer setCornerRadius:4.0f]; | |
[cancelButton.layer setMasksToBounds:YES]; | |
[cancelButton.layer setBorderWidth:1.0f]; | |
[cancelButton.layer setBorderColor: [[UIColor grayColor] CGColor]]; | |
cancelButton.frame=CGRectMake(0.0, 100.0, 60.0, 30.0); | |
[cancelButton addTarget:self action:@selector(clickOnCancelButton) forControlEvents:UIControlEventTouchUpInside]; | |
UIBarButtonItem* cancelButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cancelButton]; | |
[self.navigationItem setLeftBarButtonItem:cancelButtonItem animated:TRUE]; | |
[cancelButtonItem release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment