UINavigationBar *navigationBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, 20)];
//导航栏左边按钮
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:self action:@selector(btnClick:)];
leftItem.tag = 101;
//导航栏右边按钮
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"刷新" style:UIBarButtonItemStyleBordered target:self action:@selector(btnClick:)];
rightItem.tag = 102;
UINavigationItem* navBarItem = [[UINavigationItem alloc] initWithTitle:@"信息流广告"];
[navBarItem setLeftBarButtonItem:leftItem];
[navBarItem setRightBarButtonItem:rightItem];
navigationBar.items = [NSArray arrayWithObject:navBarItem];
[navigationBar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:navigationBar];
IOS:学习添加一个简单的UINavigationBar
最新推荐文章于 2024-09-01 16:14:50 发布