Skip to content

Instantly share code, notes, and snippets.

@MP0w
Created July 3, 2014 12:45
Show Gist options
  • Save MP0w/6c14d32b55a4bc6e6624 to your computer and use it in GitHub Desktop.
Save MP0w/6c14d32b55a4bc6e6624 to your computer and use it in GitHub Desktop.
fix iOS 7 popover presented from UIBarButtonItem(s)
// on iOS 7 present a popover from an UIBarButtonItem is buggy
// the arrow is not uncentered
// as always iOS 7 is broken setImageEdgeInsets
// try that
// the fix consist in setImageEdgeInsets:
- (UIBarButtonItem *)rightItem{
if (GBIsNativeiPad() && GBIsIOS7()) { // ios 7 sucks
UIButton *settingsButton=[UIButton buttonWithType:UIButtonTypeCustom];
settingsButton.frame=CGRectMake(0, 0, 50, 40);
[settingsButton setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
[settingsButton addTarget:self action:@selector(settings) forControlEvents:UIControlEventTouchUpInside];
[settingsButton setImageEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
return [[UIBarButtonItem alloc] initWithCustomView:settingsButton];
}
return [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"setting"] style:UIBarButtonItemStylePlain target:self action:@selector(settings)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment