如何像这样在 iOS7+ 中向导航栏添加自定义 UIView

Dev*_*nny 5 uinavigationbar uiview ios ios7 ios8

是否有插入任何一种方式UIViewNavigationBar像下面的图片?

在此处输入图片说明

sas*_*tch 1

这不行吗?

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];
Run Code Online (Sandbox Code Playgroud)