Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a custom UIView to Navigation Bar in iOS7+ like this

Is there a way to insert any UIView in NavigationBar like the image below?

enter image description here

like image 790
DevManny Avatar asked Nov 01 '22 09:11

DevManny


1 Answers

Is this not working?

UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 20.0f, 320.0f, 32.0f)];
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];

[[self view] addSubview: tempView];
[[self view] addSubview: navBar];
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle: @"Controls"];
[navBar pushNavigationItem:navItem animated:NO];
like image 125
saurabh Avatar answered Nov 12 '22 14:11

saurabh