Change the height of NavigationBar and UIBarButtonItem elements inside it in Cocoa Touch

后端 未结 6 2078
忘了有多久
忘了有多久 2020-12-23 15:19

I suppose it\'s not strictly in line with Apple guidelines but I guess it must be possible somehow. I\'d like to change the height of navigation bar inside UINavigationContr

6条回答
  •  猫巷女王i
    2020-12-23 15:28

    static CGFloat const CustomNavigationBarHeight = 74;
    
    
    @implementation WTNavigationBar
    
    
    
    - (CGSize)sizeThatFits:(CGSize)size{
        size.width = 1024;
        size.height = CustomNavigationBarHeight;
        return size;
    }
    
    -(void)layoutSubviews {
        [super layoutSubviews];
        for (UIView *view in self.subviews) {
            SFLog(@"view.class=%@",[view class]);
            if ([view isKindOfClass:NSClassFromString(@"UINavigationItemButtonView")]) {
                float centerY = self.bounds.size.height / 2.0f;
                CGPoint center = view.center;
                center.y = centerY;
                view.center = center;
            }
        }
    }
    
    
    @end
    

    in my iPad app,which has a fixed landscape orientation,I found I have to hardcode the size's width

提交回复
热议问题