views:

38

answers:

2

I have a barbuttonitem which i have customised using a custom button with an image. I want to change this image everytime after I click it. Like on and off. Once I click it it will show OFF image. Then again it will go ON image.

Is it possible?

A: 

yourButton.image = [UIImage imageNamed:@"yourImage"];

UIBarItem Documentation

Owain Hunt
It will not work like that if we want a colorful image.
wolverine
+1  A: 

Yes. In your target method just change out the UIBarButtonItem

- (void)toolbarButtonPressedAwesomeMethod {

    Do awesome stuff...

    // Change the button here…
    UIBarButtonItem *bbi = [[[UIBarButtonItem alloc] init…

    // Set it in the view
    [self.navigationItem setRightBarButtonItem:bbi];
}
coneybeare