Custom UINavigationBar with custom height causes the UIBarButtonItem's to be positioned wrong

吃可爱长大的小学妹 提交于 2019-12-02 17:17:49

Try to override layoutSubviews: call [super layoutSubviews] inside and then reposition the items.

To solve the push/pop issue use setTitleVerticalPositionAdjustment in sizeThatFits:(CGSize)size

- (CGSize)sizeThatFits:(CGSize)size {
    UIImage *img = [UIImage imageNamed:@"navigation_background.png"];
    [self setTitleVerticalPositionAdjustment:-7 forBarMetrics:UIBarMetricsDefault];
    CGRect frame = [UIScreen mainScreen].applicationFrame;
    CGSize newSize = CGSizeMake(frame.size.width , img.size.height);
    return newSize;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!