Created
July 3, 2014 12:45
-
-
Save MP0w/6c14d32b55a4bc6e6624 to your computer and use it in GitHub Desktop.
fix iOS 7 popover presented from UIBarButtonItem(s)
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
// 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