Custom navigation bar

前端 未结 6 476
故里飘歌
故里飘歌 2021-01-30 03:19

I was crawling Dribble and found the attached design. I was wondering how to do a custom navigation bar like this. I mean how create the navigation bar once and reuse it implici

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 04:09

    Using Category, add code below in your delegate file (.m)

    @implementation UINavigationBar (UINavigationBarCategory)
    
    - (void)drawRect:(CGRect)rect
    {
        UIImage *navBg = [UIImage imageNamed:@"NavBar.png"];
        [navBg drawInRect:CGRectMake(0, 0, 320, 44)];
    }
    @end
    

    Edit:

    Using Category is not a good way, I wrote a demo without using Category, click here.

提交回复
热议问题