Skip to content

Instantly share code, notes, and snippets.

@jarinosuke
Created February 7, 2014 06:05
Show Gist options
  • Save jarinosuke/8858003 to your computer and use it in GitHub Desktop.
Save jarinosuke/8858003 to your computer and use it in GitHub Desktop.
back button reframe on iOS 7
UIImage *image = [UIImage imageNamed:@"back_btn"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:image forState:UIControlStateNormal];
CGRect buttonFrame;
CGFloat padding = 0.0;
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
padding = 10.0;
}
buttonFrame = CGRectMake(padding, 0.0, image.size.width + padding * 2, image.size.height);
button.frame = buttonFrame;
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment