关于UIViewController添加UINavigationBar的详细实现方法

来源:互联网 发布:手机怎样申请淘宝店铺 编辑:程序博客网 时间:2024/06/05 06:16


- (void)setNavigationbar

{

    CGRect screenRect = [[UIScreen mainScreenbounds];

    UINavigationBar *navigationBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(00screenRect.size.width44)];

    nav.tintColor = COLOR(200100162);;

    //创建UINavigationItem

    UINavigationItem * navigationBarTitle = [[UINavigationItemalloc] initWithTitle:@"创建UINavigationBar"];

    [nav pushNavigationItem: navigationBarTitle animated:YES];

    [self.view addSubview: navigationBar];

    //创建UIBarButton 可根据需要选择适合自己的样式

    UIBarButtonItem *item = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(navigationBackButton:)];

    //设置barbutton

    navigationBarTitle.leftBarButtonItem = item;

    [navigationBar setItems:[NSArray arrayWithObject: navigationBarTitle]];

  

}

0 0
原创粉丝点击