I am trying to make a button shrink/expand upon touch using the code below.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *myTouch = [touches anyObject];
UIView *view = [myTouch view];
view.transform = CGAffineTransformMakeScale(0.7, 0.7);<--IS THIS correct??
CAKeyframeAnimation *scale = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
scale.duration = 0.8;
scale.values = @[@1.0, @0.7, @0.9, @0.7, @0.8, @0.7];
scale.keyTimes = @[@0.13, @0.26, @0.39, @0.52, @0.65, @0.8];
scale.repeatCount = 1;
scale.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[view.layer addAnimation:scale forKey:@"scaleAnimation"];
}
Finally I want the keep button in the shrunk state after touch ended.
1. Where should I try to permanently change the layers scale? TouchesBegan? TouchesEnded?
2. How should I do that? (see "<=== Is this correct?" line)