Just do like this.. You will get correct solution..
-(void)setSegmentValues:(NSArray *)values bgColor:(UIColor *)color
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectedIndexValue:)];
tap.numberOfTapsRequired = 1;
tap.numberOfTouchesRequired = 1;
viewOne = [[UIView alloc]initWithFrame:CGRectMake(40, 50, 80, 60)];
viewOne.backgroundColor = color;
viewOne.tag = 0;
UILabel *lblOne = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, 60)];
lblOne.text = [values objectAtIndex:0];
lblOne.textAlignment = UITextAlignmentCenter;
lblOne.backgroundColor = [UIColor clearColor];
[viewOne addSubview:lblOne];
viewOne.userInteractionEnabled = YES;
[viewOne addGestureRecognizer:tap];
[self addSubview:viewOne];
}
-(void)selectedIndexValue:(UIGestureRecognizer *)gesture
{
int myViewTag = gesture.view.tag;
if (myViewTag == 0)
{
selectedIndex1 = 0;
self.lblValue.text = [valueArray objectAtIndex:myViewTag];
viewOne.backgroundColor = [UIColor colorWithRed:57.0f green:122.0f blue:255.0f alpha:1.0f];
viewTwo.backgroundColor = viewColor;
viewThree.backgroundColor = viewColor;
}
[self sendActionsForControlEvents:UIControlEventValueChanged];
}