Implemented some barbuttons by using below code,
UISegmentedControl *button = [[[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:@"", nil]] autorelease];
button.momentary = YES;
button.segmentedControlStyle = UISegmentedControlStyleBar;
UIBarButtonItem *barButton = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
I used set action for the button using this code,
[button addTarget:self
action:@selector(drawOnImageByColor:)
forControlEvents:UIControlEventTouchUpInside];