概述
本文介绍一个仿iOS猎豹垃圾清理的demo App。它实现了以下主要功能:
获取设备已安装App列表已经App信息
扫描动画的实现
获取已用存储和可用存储
垃圾清理
下面讲解各个主要功能的实现。
获取设备已安装App列表
扫描动画的实现
这里主要有两个动画。
利用UIScrollView, 实现每个App自动滚动。
Animation动画, 中间扫描线的往返运动。
- (void)addScanLineAnimation
{
ScanLineIV *mySL = [[ScanLineIV alloc]initWithFrame:CGRectMake((self.view.frame.size.width - 156)/2, 300, 156, 90)];
[self.view addSubview:mySL];
/* 向左移动 */
CABasicAnimation *animationLeft = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
// 动画选项的设定
animationLeft.duration = 0.5f; // 持续时间
animationLeft.beginTime = 0.0f;
animationLeft.autoreverses = YES; // 结束后执行逆动画
// 动画先加速后减速
animationLeft.timingFunction =
[CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
// 终了帧
animationLeft.toValue = [NSNumber numberWithFloat:-40];;
/* 向右移动 */
CABasicAnimation *animationRight = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
// 动画选项的设定
animationRight.duration = 0.5f; // 持续时间
animationRight.beginTime = 1.0f;
animationRight.autoreverses = YES; // 结束后执行逆动画
// 动画先加速后减速
animationRight.timingFunction =
[CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
// 终了帧
animationRight.toValue = [NSNumber numberWithFloat:40];;
/* 动画组 */
CAAnimationGroup *group = [CAAnimationGroup animation];
group.delegate = self;
group.duration = 2.0;
group.repeatCount = 15;
// 动画结束后不变回初始状态
group.removedOnCompletion = NO;
group.fillMode = kCAFillModeForwards;
// 添加动画
group.animations = [NSArray arrayWithObjects:animationLeft, animationRight, nil];
[mySL.layer addAnimation:group forKey:@"moveLeft-moveRight-layer"];
}