gpt4 book ai didi

ios - 如何制作 uibutton zoomout 然后 crossblur?

转载 作者:行者123 更新时间:2023-11-29 02:04:28 25 4
gpt4 key购买 nike

我已经实现了一个 UIButton 动画,至于现在它会缩放,但我还想在 UIButton 消失时交叉淡入淡出。

这是我的按钮动画示例代码。

(void)centerButtonAnimation{
CAKeyframeAnimation *centerZoom = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
centerZoom.duration = 1.5f;
centerZoom.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.5, 1.5, 1.5)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(4, 4, 4)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(5, 5, 5)]];
centerZoom.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
centerButton.transform = CGAffineTransformMakeScale(5, 5);
[centerButton.layer addAnimation:centerZoom forKey:@"buttonScale"];
[centerButton setUserInteractionEnabled:NO];
}

最佳答案

要链接动画,您可以将您的类设置为动画的委托(delegate)。

@property CAKeyframeAnimation *centerZoom;

- (void) centerButtonAnimation
{
self.centerZoom = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

// Set the delegate to this instance.
centerZoom.delegate=self;

centerZoom.duration = 1.5f;
centerZoom.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.5, 1.5, 1.5)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(4, 4, 4)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(5, 5, 5)]];
centerZoom.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
centerButton.transform = CGAffineTransformMakeScale(5, 5);
[centerButton.layer addAnimation:centerZoom forKey:@"buttonScale"];
[centerButton setUserInteractionEnabled:NO];
}

- (void) crossFadeAnimation
{
// Insert animation code for cross fade.
}

然后实现委托(delegate)函数来检测动画的结束。如果是缩放结束,则开始交叉淡入淡出。

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
if ((theAnimation == self.centerZoom) && flag){
[self crossFadeAnimation];
}
}

关于ios - 如何制作 uibutton zoomout 然后 crossblur?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29941058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com