1

I have created a AVFoundation Camera,now i want to change toolbar item image to my custom image , when user tap record camera button than image will change.

I have done that change but problem is that my image display black and white no color.soplz help on this.

My code is:

- (void)viewDidLoad

{
[[self recordButton] setImage:[UIImage imageNamed:@"camara30.png"]]  //first time setting image
}

- (void)captureManagerRecordingBegan:(AVCamCaptureManager *)captureManager
{
    CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, ^(void) {
       // [[self recordButton] setTintColor:[UIColor redColor]];
        [[self recordButton] setImage:[UIImage imageNamed:@"record30.png"]];   //changing image when record begun
        [[self recordButton] setEnabled:YES];
    });
}

- (void)captureManagerRecordingFinished:(AVCamCaptureManager *)captureManager
{
    CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, ^(void) {
        [[self recordButton] setImage:[UIImage imageNamed:@"camara30.png"]];   //changing image when record end
        [[self recordButton] setEnabled:YES];
    });
}

My first screen before start recording:

enter image description here

My second screen after end recording:

enter image description here

2 Answers2

0
    UIBarButtonItem *temp = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"BlueMarbleDrop"] forState:UIControlStateNormal];
    button.frame=CGRectMake(0.0, 0.0, 60.0, 30.0);
    [button addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* stopBtn = [[UIBarButtonItem alloc] initWithCustomView:button];

    [self.toolBar setItems:[NSArray arrayWithObjects:temp,stopBtn,temp, nil]];

the output look like enter image description here

i took this from UIBarButtonItem with color?

Community
  • 1
  • 1
Shineeth Hamza
  • 1,279
  • 10
  • 17
  • it does not working instead of image it displaying blank place which is clickable. –  Nov 01 '12 at 09:38
  • i tested this peace of code and the out put look like the image i posted. the blue dot on the top is a toolbar button... – Shineeth Hamza Nov 01 '12 at 09:53
0

Try to set image [[self recordButton] setImage:[UIImage imageNamed:@"record30.png"] forState:UIControlStateNormal];

Sanjeev sharma
  • 169
  • 1
  • 6