0
아래 코드를 사용하여 터치시 축소/확대 버튼을 만들려고합니다.CAKeyFrameAnimation : 최종 위치/스케일을 어디에/어떻게 설정합니까?
- (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"];
}
마지막으로 터치가 끝난 후에 축소 버튼이 유지되도록합니다.
1. Where should I try to permanently change the layers scale? TouchesBegan? TouchesEnded?
2. How should I do that? (see "<=== Is this correct?" line)
감사합니다! 나는 그것을 바로 시도 할 것이다! –
이것은 버튼을 진동시키는 완벽한 솔루션입니다. 그러나 최종 스케일을 얻고 그에 따라 버튼 크기를 어떻게 설정합니까? 지금은 원래 크기로 다시 터져 나옵니다. 완료 블록에서 0.5로 변환을 시도했지만 작동하지 않습니다 - 감사합니다 .. –
@ iphone-noob이 방법을 사용하여 0.7의 눈금을 유지해야합니다. 이것은'view.transform = ... '처럼 스케일을 변경합니다. 애니메이션 항목을 제거하고 여기에 변형을 설정하면 어떻게됩니까? – Fogmeister