iPhone - How set uinavigationbar height?

后端 未结 9 2331
情歌与酒
情歌与酒 2020-11-28 05:25

I want to make the top of the navigation view a bit smaller. How would you achieve this? This is what I\'ve tried so far, but as you can see, even though I make the navigati

9条回答
  •  醉酒成梦
    2020-11-28 06:16

    I am a newbie in ios yet. I solved the problem in following way :

    1. I have created a new class that inherits from UINavigationBar

    2. I override the following method :

       (void)setBounds:(CGRect)bounds {
      
         [super setBounds:bounds];
         self.frame = CGRectMake(0, 0, 320, 54);
      
      
        }
      

    3.To get a custom background of the navigation bar, I overrided the following method :

    -(void)drawRect:(CGRect)rect {
    
        [super drawRect:rect];
    
        UIImage *img = [UIImage imageNamed:@"header.png"];
    
        [img drawInRect:CGRectMake(0,0, self.frame.size.width, self.frame.size.height)];
    
    
    }
    
    1. In xib file, I have changed the default UINavigationBar class of the navigation bar to my class.

提交回复
热议问题