UINavigationBar - 导航Bar(UINavigationItem)

UINavigationBar

  • 属性
    // 标题
//    self.navigationController.navigationBar.titleTextAttributes = @{};
//    self.navigationController.navigationBar.shadowImage = [UIImage imageNamed:@"iconfont-rijizhangicon-2"];
    
    // 颜色
    self.navigationController.navigationBar.tintColor = [UIColor redColor];
    self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];
    
    // 背景
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"iconfont-rijizhangicon-2"]
//                                                  forBarMetrics:UIBarMetricsDefault];
//    
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"iconfont-rijizhangicon-2"]
//                                                 forBarPosition:UIBarPositionTop
//                                                     barMetrics:UIBarMetricsDefault];
    

    // 返回icon
//    self.navigationController.navigationBar.backIndicatorImage = [UIImage imageNamed:@"iconfont-rijizhangicon-2"];
//    self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"iconfont-rijizhangicon-2"];
    

UIBarButtonItem

  • 系统已有item
    self.navigationItem.title = @"title";
    self.navigationItem.titleView = [UIView new];// title 对应的View
    self.navigationItem.prompt = @"dfghjklkjhgf";//
  • 添加 item
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"编辑"
                                                                  style:UIBarButtonItemStylePlain
                                                                 target:self
                                                                 action:@selector(rightItemHandler)];
    
    [self.navigationItem setRightBarButtonItem:rightItem animated:YES];// leftItem 最好不要使用,使用系统自带的back,以及左侧右滑pop

你可能感兴趣的:(UINavigationBar - 导航Bar(UINavigationItem))