Custom navigation bar

前端 未结 6 601
故里飘歌
故里飘歌 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 03:53

    set a custom background for the NavigationBar

    UIImage *navBackground =[[UIImage imageNamed:@"navbarBackground"] 
                     resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearance] setBackgroundImage:navBackground forBarMetrics:UIBarMetricsDefault];
    

    then in your View Controller set custom views for left, rightBarButtons and title.

    self.navigationItem.titleView = customTitleView;
    self.navigationItem.leftBarButtonItem = customBarButton;
    self.navigationItem.rightBarButtonItem = customBarButton2;
    

提交回复
热议问题