Skip to content

Instantly share code, notes, and snippets.

@dennda
Created November 17, 2011 20:41
Show Gist options
  • Save dennda/1374454 to your computer and use it in GitHub Desktop.
Save dennda/1374454 to your computer and use it in GitHub Desktop.
UILabel *label = [UILabel new];
label.text = locked ? @"🔒" : @"🔓";
UIBarButtonItem *lockBtn = [[UIBarButtonItem alloc] initWithCustomView:label];
lockBtn.tintColor = [UIColor redColor];
// UIBarButtonItem *lockBtn = [[UIBarButtonItem alloc] initWithTitle:title
// style:UIBarButtonItemStyleBordered
// target:nil action:nil];
NSMutableArray *rightBarButtonItems = [self.navigationItem.rightBarButtonItems mutableCopy];
[rightBarButtonItems insertObject:lockBtn atIndex:0];
self.navigationItem.rightBarButtonItems = rightBarButtonItems;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment