uinavigationBar常用设置

设置背景颜色

    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];

设置字体颜色

    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

或者

    [self.navigationController.navigationBar setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}];

添加系统自带的按钮

   UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"style:UIBarButtonItemStyleDone target:nil action:nil];
   self.navigationItem.rightBarButtonItem = rightButton;

自定义item

    UIButton *servicebtn = [UIButton buttonWithType:UIButtonTypeCustom];
    servicebtn.frame = CGRectMake(0, 0, 30, 30);
    [servicebtn setBackgroundImage:[UIImage imageNamed:@"user"] forState:UIControlStateNormal];
    [servicebtn addTarget:self action:@selector(callService) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:servicebtn];
    self.navigationItem.rightBarButtonItem = item; 



发布了100 篇原创文章 · 获赞 216 · 访问量 22万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章