ios - How to display UIImage in UINavigationBar programmatically in UIViewController -
i trying add uinavigationbar programmatically. adding successfully. , after want add uiimage uinavigationbar. not displayed however. , also, how can add text programmatically in uinavigationbar?
this code:
- (void)viewdidload { uinavigationbar *navibarobj = [[uinavigationbar alloc] initwithframe:cgrectmake(0, 0, 320, 44)]; [self.view addsubview:navibarobj]; self.navigationitem.titleview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"logoicon.png"]]; }
you need set items of navigation bar. done navigation controller in case own navigation bar need manually:
navibarobj.items = @[ self.navigationitem ]; if want both image , text in middle of navigation bar need create uiview , add both uiimageview , uilablel it, add view titleview.
Comments
Post a Comment