IOS navigationItem 设置返回按钮,title图片和rightBarButtonItem

1.自定义返回按钮


    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:nil action:nil];

    [self.moreItem setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

    [self.navigationItem setBackBarButtonItem:backItem];


    若想使返回按钮不可用
            self .navigationItem.leftBarButtonItem =  nil ;

2.设置标题图片

 self.navigationItem.titleView = [[UIImageViewalloc] initWithImage: [[UIImageimageNamed:@"barLogo.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];


3.设置rightBarButtonItem

self.navigationItem.rightBarButtonItem=[[UIBarButtonItemalloc] initWithImage:[UIImageimageNamed:@"MoreImage.png"]style:UIBarButtonItemStylePlaintarget:selfaction:@selector(rightItemPress)];

若想使 rightBarButtonItem不可用
            self .navigationItem.rightBarButtonItem nil ;

你可能感兴趣的:(MAC,Objective-C,Xcode)