Skip to content

Instantly share code, notes, and snippets.

@hugo53
Created July 26, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugo53/620fc6f913f7b818d376 to your computer and use it in GitHub Desktop.
Save hugo53/620fc6f913f7b818d376 to your computer and use it in GitHub Desktop.
UIButton *backButton = [[UIButton alloc] init];
[backButton addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
backButton.titleLabel.font = [UIFont fontWithName:@"ivvi-app-thumbnav-icons" size:34];
[backButton setTitle:@"\ue820" forState:UIControlStateNormal];
[backButton setTitleColor:[UIColor ivviNavigationTitle] forState:UIControlStateNormal];
CGFloat leftInset = [self.navigationController.navigationBar respondsToSelector:@selector(layoutMargins)] ? 14 : 10;
backButton.frame = CGRectMake(0, 0.0f, 44.0f, 44.0f);
backButton.contentEdgeInsets = UIEdgeInsetsMake(0, -leftInset, 0, 20);
[backButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60.0f, 44.0f)];
view.userInteractionEnabled = YES;
[view addSubview:backButton];
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = customBarItem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment