我在分析应用程序时收到警告,我正在附上屏幕截图,
我正在初始化期间为Dead store存储animationForButton2
从未读过


button_2是自定义UIButton的位置,如何关闭此警告..?

最佳答案

只需替换以下行:

CAKeyframeAnimation *animationForButton2 = [CAKeyframeAnimation animation];
animationForButton2 = [CAKeyframeAnimation animationWithKeyPath:@"position"];




CAKeyframeAnimation *animationForButton2 = [CAKeyframeAnimation animationWithKeyPath:@"position"];


在原始代码示例中,用animationForButton2实例化CAKeyframeAnimation是没有意义的,只是丢弃它并在下一行将其替换为另一个CAKeyframeAnimation

10-07 20:54