// 某電商app首頁的tableViewCell中有這種效果.
// 挺好玩的
// 做旋轉動畫的圖片
UIImageView *ggIV = [[UIImageView alloc] init];
ggIV.frame = CGRectMake(78, 38, 19, 35);
ggIV.image = [UIImage imageNamed:@"gg"];
// 改錨點到top中間
ggIV.layer.anchorPoint = CGPointMake(0.5, 0.0);
[V addSubview: ggIV];
self.ggIV = ggIV;
// 圍繞z軸 旋轉動畫
CABasicAnimation *momAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
momAnimation.fromValue = [NSNumber numberWithFloat:-M_PI_4];
momAnimation.toValue = [NSNumber numberWithFloat:M_PI_4];
momAnimation.duration = 0.7;
momAnimation.repeatCount = CGFLOAT_MAX;
// 自動反轉
momAnimation.autoreverses = YES;
// 給個旋轉動畫
[self.ggIV.layer addAnimation:momAnimation forKey:@"animateLayer"];
某電商旋轉動畫
某電商旋轉動畫
// 雷達動畫
// 某外賣類app的首頁效果不錯
// 用工具分析界面構成并提取出圖片資源模仿之
- (void)Addradar
{
UIView *containerV = [[UIView alloc] init];
containerV.frame = CGRectMake(100, 200, 220, 220);
containerV.backgroundColor = [UIColor grayColor];
[self.view addSubview: containerV];
// 背景圖 有兩個圓圈的
UIImageView *bg = [[UIImageView alloc] init];
bg.frame = containerV.bounds;
bg.image = [UIImage imageNamed: @"radar_bg"];
[containerV addSubview: bg];
// 放大縮小的4個點圖
UIImageView *i1 = [[UIImageView alloc] init];
i1.frame = CGRectMake(53, 58, 11, 15);
i1.image = [UIImage imageNamed: @"icon1"];
i1.transform = CGAffineTransformScale(i1.transform, 0.1, 0.1);
[containerV addSubview: i1];
[self iconScaleWithImageView: i1 beginTime: 0.8];
UIImageView *i2 = [[UIImageView alloc] init];
i2.frame = CGRectMake(125, 80, 11, 15);
i2.image = [UIImage imageNamed: @"icon2"];
i2.transform = CGAffineTransformScale(i1.transform, 0.1, 0.1);
[containerV addSubview: i2];
[self iconScaleWithImageView: i2 beginTime: 0.2];
UIImageView *i3 = [[UIImageView alloc] init];
i3.frame = CGRectMake(60, 155, 11,15);
i3.image = [UIImage imageNamed: @"icon3"];
i3.transform = CGAffineTransformScale(i1.transform, 0.1, 0.1);
[containerV addSubview: i3];
[self iconScaleWithImageView: i3 beginTime: 0.6];
UIImageView *i4 = [[UIImageView alloc] init];
i4.frame = CGRectMake(155, 130, 11, 15);
i4.image = [UIImage imageNamed: @"icon4"];
i4.transform = CGAffineTransformScale(i1.transform, 0.1, 0.1);
[containerV addSubview: i4];
[self iconScaleWithImageView: i4 beginTime: 0.4];
// 中間旋轉的雷達指針圖片
UIImageView *radarIV = [[UIImageView alloc] init];
radarIV.frame = CGRectMake(0, 0, 220, 220);
radarIV.image = [UIImage imageNamed: @"radar_s"];
[containerV addSubview:radarIV];
// 給個旋轉動畫
CABasicAnimation *radarRotation = [CABasicAnimation animation];
radarRotation.keyPath = @"transform.rotation";
radarRotation.toValue = @(2 * M_PI);
radarRotation.duration = 2.8;
radarRotation.repeatCount = MAXFLOAT;
radarRotation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[radarIV.layer addAnimation:radarRotation forKey:@"radarRotation"];
}
// 4個點的放大縮小動畫
- (void)iconScaleWithImageView:(UIImageView *)IV beginTime:(CGFloat)beginTime
{
CABasicAnimation *scaleA = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleA.fromValue = @0.1;
scaleA.toValue = @1.0;
scaleA.autoreverses = YES;
scaleA.repeatCount = MAXFLOAT;
scaleA.duration = 0.8;
scaleA.removedOnCompletion = NO;
scaleA.fillMode = kCAFillModeForwards;
scaleA.beginTime = CACurrentMediaTime() + beginTime;
[IV.layer addAnimation:scaleA forKey:@"IV"];
}
某外賣旋轉動畫
某外賣旋轉動畫
// 網易新聞的下拉刷新動畫 縮放+移動
UIView *containerV = [[UIView alloc] init];
containerV.frame = CGRectMake(100, 200, 50, 30);
[self.view addSubview:containerV];
UIImageView *bgIV = [[UIImageView alloc] init];
bgIV.frame = CGRectMake(10, 0, 30, 30);
bgIV.image = [UIImage imageNamed:@"refresh_sphere"];
[containerV addSubview:bgIV];
UIImageView *circleIV = [[UIImageView alloc] init];
circleIV.frame = CGRectMake(0, 8, 50, 15);
circleIV.image = [UIImage imageNamed:@"refresh_circle"];
[containerV addSubview:circleIV];
// 綻放動畫
CABasicAnimation *scaleBA = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleBA.fromValue = [NSNumber numberWithFloat:0.5];
scaleBA.toValue = [NSNumber numberWithFloat:1.0];
scaleBA.repeatCount = MAXFLOAT;
scaleBA.autoreverses = YES;
scaleBA.duration = 0.7;
// Y值動畫
CABasicAnimation *transBA = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
transBA.fromValue = [NSNumber numberWithFloat:-8.];
transBA.toValue = [NSNumber numberWithFloat:8.];
transBA.repeatCount = MAXFLOAT;
transBA.autoreverses = YES;
transBA.duration = 1.4;
CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
group.animations = @[scaleBA, transBA];
group.repeatCount = MAXFLOAT;
group.duration = 2.8;
[circleIV.layer addAnimation:group forKey:@"GROUP"];
網易新聞的下拉刷新動畫 縮放+移動
http://i12.tietuku.com/58ab081217e557b2.gif