I was able to change the vertical position of the back button icon, but not the text.
I use the layoutSubviews method in a UINavigationBar:
- (void)layoutSubviews { [super layoutSubviews]; BOOL fixed = NO; NSArray *classNamesToReposition = @[@"_UINavigationBarBackIndicatorView", @"UINavigationButton", @"UINavigationItemButtonView"]; for (UIView *view in [self subviews]) { if ([classNamesToReposition containsObject:NSStringFromClass([view class])] && !fixed) { CGRect frame = [view frame]; if ([NSStringFromClass([view class]) isEqualToString:@"_UINavigationBarBackIndicatorView"]) { frame.origin.y = 14.5; } else if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationButton"]) { frame.origin.y = 9.0; } else if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationItemButtonView"]) { frame.origin.y = 5.0; } [view setFrame:frame]; } } }
The problem is that any frame change that I make in the UINavigationItemButtonView does not seem to have any effect, nor any frame change that I make on it. The true representation of UILabel is the actual text of the button. When I register views, frames seem to change, but the text does not move in my view. What am I doing wrong?
source share