Hi,
How do I get rid of these warnings
"Warning:'UIButton' may not respond to '-setPosition:'
and
"Warning:'UIButton' may not respond to '-addAnimation:forKey'
I get them here:
- (void)monBtnIn {
[monButton setPosition:CGPointMake(113.5,256.5)];
[monButton addAnimation:[self monInAnimation]
forKey:@"position"];
}
Everything builds and loads fine but I dont like warnings. I assume its something to do with the fact that its a UIButton and not a CALayer.
So, how do I make this work for a UIButton?
the .h file
IBOutlet UIButton *monButton;
This is the KeyFrameAnimation - it creates a 'springy' animation that settles.
- (CAAnimation*)monInAnimation {
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path,NULL,113,520);
CGPathAddLineToPoint(path, NULL, 113.5, 286);
CGPathAddLineToPoint(path, NULL, 113.5, 242);
CGPathAddLineToPoint(path, NULL, 113.5, 270);
CGPathAddLineToPoint(path, NULL, 113.5, 250);
CGPathAddLineToPoint(path, NULL, 113.5, 262);
CGPathAddLineToPoint(path, NULL, 113.5, 254);
CGPathAddLineToPoint(path, NULL, 113.5, 258);
CGPathAddLineToPoint(path, NULL, 113.5, 256.5);
CAKeyframeAnimation *
animation = [CAKeyframeAnimation
animationWithKeyPath:@"position"];
[animation setPath:path];
[animation setDuration:1.5];
NSArray *arr = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.12],
[NSNumber numberWithFloat:0.24],
[NSNumber numberWithFloat:0.36],
[NSNumber numberWithFloat:0.48],
[NSNumber numberWithFloat:0.60],
[NSNumber numberWithFloat:0.72],
[NSNumber numberWithFloat:0.84],
[NSNumber numberWithFloat:1.0],nil];
[animation setKeyTimes:arr];
[animation setTimingFunctions:[NSArray arrayWithObjects:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], nil]];
//[animation setAutoreverses:YES];
CFRelease(path);
return animation;
}
Thank you very much in advance for you help!