ok, i solved removing my custom button class and implementing a "normal" UIButton setting the UIControlState as showed into the enum provided by Ramshad.
I could implement also a UIBezierPath loading it into a separate UIImage* object
this is the code i used into ViewController.m at least:
- this part to set the UIImage to the bezier object
this to implement the button change at touch:
-(UIImage*) preTouch{
CGRect rect = CGRectMake(0.0, 0.0, 100.0, 100.0);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsBeginImageContext(rect.size);
UIColor* color2 = [UIColor colorWithRed:1 green:0.933 blue:0.8 alpha:1];
UIColor* color3 = [UIColor colorWithRed:1 green:0.114 blue:0.114 alpha:1];
NSArray* gradientColors = [NSArray arrayWithObjects:
(id)color2.CGColor,
(id)[UIColor colorWithRed:1 green:0.524 blue:0.457 alpha:1].CGColor,
(id)color3.CGColor,nil];
CGFloat gradientLocations[] = {0, 1};
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)(gradientColors), gradientLocations);
UIBezierPath* newBezier = [UIBezierPath bezierPath];//]WithArcCenter:CGPointMake(32.2, 30) radius:0.5 startAngle:5 endAngle:50 clockwise:YES];
[newBezier moveToPoint:CGPointMake(31.48, 59.3)];
[newBezier addLineToPoint:CGPointMake(17.81, 65.66)];
[newBezier addLineToPoint:CGPointMake(39.29, 67.25)];
[newBezier addLineToPoint:CGPointMake(51, 89.5)];
[newBezier addLineToPoint:CGPointMake(56.86,68.84)];
[newBezier addLineToPoint:CGPointMake(92, 59.3)];
[newBezier addLineToPoint:CGPointMake(63.69, 50.56)];
[newBezier addLineToPoint:CGPointMake(76.38, 0.5)];
[newBezier addLineToPoint:CGPointMake(51,45)];
[newBezier addLineToPoint:CGPointMake(31.48,16.39)];
[newBezier addLineToPoint:CGPointMake(39.29,45)];
[newBezier addLineToPoint:CGPointMake(10,35.46)];
[newBezier addLineToPoint:CGPointMake(31.48,59.3)];
[newBezier closePath];
newBezier.miterLimit = 18;
[color3 setFill];
[newBezier fill];
CGContextSaveGState(context);
[newBezier addClip];
CGContextDrawRadialGradient(context, gradient, CGPointMake(118.72, 52.63), 3.79,
CGPointMake(107.76, 55.37), 94.63,
kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
CGContextRestoreGState(context);
CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
CGContextAddPath(context, newBezier.CGPath);
UIImage *buttonImage1 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsPopContext();
UIGraphicsEndImageContext();
return buttonImage1;}
and this to set behavior as the button is touched
- (IBAction)buttonPressed: (UIButton*) sender{
UIImage* buttonImage = [[UIImage alloc]init];
buttonImage = [self preTouch];
UIImage* myImage = buttonImage;
[newButton setBackgroundImage: myImage forState:1 <<0];
thanks again for supporting