Friday, May 31, 2013

UIBarButtonItem setBackgroundVerticalPositionAdjustment example in Objective C (iOS).


UIBarButtonItem setBackgroundVerticalPositionAdjustment


Sets the background vertical position offset for given bar metrics.

- (void)setBackgroundVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics

Parameters
adjustment
The background vertical position offset for barMetrics.
barMetrics
Bar metrics.

Discussion of [UIBarButtonItem setBackgroundVerticalPositionAdjustment]
This offset is used to adjust the vertical centering of bordered bar buttons within the bar.

UIBarButtonItem setBackgroundVerticalPositionAdjustment example.
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleDone target:self action:nil];
[button setBackgroundVerticalPositionAdjustment:-20.0f forBarMetrics:UIBarMetricsDefault];
[[self navigationItem] setRightBarButtonItem:button];

Example of [UIBarButtonItem setBackgroundVerticalPositionAdjustment].
float my_offset_plus_or_minus = 3.0f;

UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithTitle:@"title"
                                                          style:UIBarButtonItemStyleDone
                                                          target:someObject action:@selector(someMssage)];

[right setBackgroundVerticalPositionAdjustment:my_offset_plus_or_minus forBarMetrics:UIBarMetricsDefault];

End of UIBarButtonItem setBackgroundVerticalPositionAdjustment example article.