Is it possible to position a custom image UIBarButton item on the left or right edge of a UINavigationBar? The way I've created my buttons it looks best if the edge of the button is touching the edge of the UINavigationBar.
Your best bet here is subclassing UINavigation bar and overriding layout subviews.
In my example I move my button to the far left edge if it has a tag of 900.
- (void) layoutSubviews {
[super layoutSubviews];
//override the navigation bar to move classes with 900 to the ledge
for (UIView *view in self.subviews) {
if ([view isKindOfClass:[UIButton class]]) {
if (view.tag == 900)
view.frame = CGRectMake(0,0, 88, 44);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With