UIBarButtonItem UIBarMetricsLandscapePhone
UIBarMetrics
Constants to specify metrics to use for appearance.
typedef enum {
UIBarMetricsDefault,
UIBarMetricsLandscapePhone,
} UIBarMetrics;
Constants
UIBarMetricsDefault
Specifies default metrics for the device.
UIBarMetricsLandscapePhone
Specifies metrics for landscape orientation using the phone idiom.
UIBarButtonItem UIBarMetricsLandscapePhone example.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundVerticalPositionAdjustment:-3 forBarMetrics: UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackButtonBackgroundVerticalPositionAdjustment:-3 forBarMetrics: UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundVerticalPositionAdjustment:3 forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setBackButtonBackgroundVerticalPositionAdjustment:3 forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackButtonBackgroundVerticalPositionAdjustment:-3 forBarMetrics: UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setBackgroundVerticalPositionAdjustment:3 forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setBackButtonBackgroundVerticalPositionAdjustment:3 forBarMetrics:UIBarMetricsDefault];
Example of [UIBarButtonItem UIBarMetricsLandscapePhone].
-(void)toggleAppearanceStyles:(NSNotification *)note {
UIImage *barButtonBgImage = nil;
UIImage *barButtonBgImageActive = nil;
if([note.userInfo[@"flag"] boolValue]) {
barButtonBgImage = [[UIImage imageNamed:@"g_barbutton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 4, 15, 4)];
barButtonBgImageActive = [[UIImage imageNamed:@"g_barbutton_active.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 4, 15, 4)];
}
[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics: UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImageActive forState:UIControlStateSelected barMetrics: UIBarMetricsLandscapePhone];
}
UIImage *barButtonBgImage = nil;
UIImage *barButtonBgImageActive = nil;
if([note.userInfo[@"flag"] boolValue]) {
barButtonBgImage = [[UIImage imageNamed:@"g_barbutton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 4, 15, 4)];
barButtonBgImageActive = [[UIImage imageNamed:@"g_barbutton_active.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 4, 15, 4)];
}
[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics: UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImageActive forState:UIControlStateSelected barMetrics: UIBarMetricsLandscapePhone];
}
UIBarButtonItem UIBarMetricsLandscapePhone example.
UIImage *doneBackgroundImage = [[UIImage imageNamed:@"button_done.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
[[UIBarButtonItem appearance] setBackgroundImage:doneBackgroundImage
forState:UIControlStateNormal
style:UIBarButtonItemStyleDone
barMetrics: UIBarMetricsLandscapePhone];
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
[[UIBarButtonItem appearance] setBackgroundImage:doneBackgroundImage
forState:UIControlStateNormal
style:UIBarButtonItemStyleDone
barMetrics: UIBarMetricsLandscapePhone];