簡單旋轉動畫

// 某電商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



參考資料
1: https://github.com/EnjoySR/ESRefreshControl

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,825評論 6 546
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,814評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,980評論 0 384
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 64,064評論 1 319
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,779評論 6 414
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 56,109評論 1 330
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 44,099評論 3 450
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,287評論 0 291
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,799評論 1 338
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,515評論 3 361
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,750評論 1 375
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,221評論 5 365
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,933評論 3 351
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,327評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,667評論 1 296
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,492評論 3 400
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,703評論 2 380

推薦閱讀更多精彩內容