旋轉(zhuǎn)動圖(Objective - C)

#import "ViewController.h"

@interface ViewController ()

@property UILabel *lable1;

@property UILabel *lable2;

@property UILabel *lable3;

@property UILabel *lable4;

@end

@implementation ViewController- (void)viewDidLoad {? ?

?[super viewDidLoad];? ?

?//背景色? ??

self.view.backgroundColor = [UIColor cyanColor];? ??

//Lable? ??

self.lable1 = [UILabel new];? ??

self.lable1.frame = CGRectMake(0, 0, 100, 100);? ??

self.lable1.center = CGPointMake(207, 200);? ?

?self.lable1.backgroundColor = [UIColor grayColor];? ??

self.lable1.text = @"好";? ??

self.lable1.textAlignment = NSTextAlignmentCenter;? ??

self.lable1.font = [UIFont systemFontOfSize:60];? ??

self.lable1.layer.cornerRadius = 50;? ??

self.lable1.layer.masksToBounds = YES;? ??

[self.view addSubview:self.lable1];? ??

self.lable2 = [UILabel new];? ??

self.lable2.frame = CGRectMake(0, 0, 100, 100);? ??

self.lable2.center = CGPointMake(60, 350);? ??

self.lable2.backgroundColor = [UIColor grayColor];? ??

self.lable2.text = @"好";? ?

?self.lable2.textAlignment = NSTextAlignmentCenter;? ??

self.lable2.font = [UIFont systemFontOfSize:60];? ??

self.lable2.layer.cornerRadius = 50; ??

self.lable2.layer.masksToBounds = YES;? ??

[self.view addSubview:self.lable2];? ??

self.lable3 = [UILabel new];? ?

self.lable3.frame = CGRectMake(0, 0, 100, 100);? ??

self.lable3.center = CGPointMake(207, 500);? ??

self.lable3.backgroundColor = [UIColor grayColor];? ??

self.lable3.text = @"學";? ??

self.lable3.textAlignment = NSTextAlignmentCenter;? ??

self.lable3.font = [UIFont systemFontOfSize:60];? ?

?self.lable3.layer.cornerRadius = 50;? ??

self.lable3.layer.masksToBounds = YES;? ??

[self.view addSubview:self.lable3];? ??

self.lable4 = [UILabel new];? ??

self.lable4.frame = CGRectMake(0, 0, 100, 100);? ??

self.lable4.center = CGPointMake(354, 350);? ??

self.lable4.backgroundColor = [UIColor grayColor];? ??

self.lable4.text = @"習";? ??

self.lable4.textAlignment = NSTextAlignmentCenter;? ??

self.lable4.font = [UIFont systemFontOfSize:60];? ??

self.lable4.layer.cornerRadius = 50;? ??

self.lable4.layer.masksToBounds = YES;? ??

[self.view addSubview:self.lable4];

}

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event{

//關(guān)鍵幀動畫

//持續(xù)時間? 延遲

[UIView animateKeyframesWithDuration:8 delay:0.1 options:(UIViewKeyframeAnimationOptionAutoreverse) animations:^{

[UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.25 animations:^{

self.lable1.center = CGPointMake(133, 275);

self.lable1.transform = CGAffineTransformMakeRotation(M_PI);

self.lable2.center = CGPointMake(133, 425);

self.lable2.transform = CGAffineTransformMakeRotation(M_PI);

self.lable3.center = CGPointMake(280, 425);

self.lable3.transform = CGAffineTransformMakeRotation(M_PI);

self.lable4.center = CGPointMake(280, 275);

self.lable4.transform = CGAffineTransformMakeRotation(M_PI);

}];

[UIView addKeyframeWithRelativeStartTime:0.25 relativeDuration:0.25 animations:^{

self.lable1.center = CGPointMake(414/2, 736/2);

self.lable1.transform = CGAffineTransformRotate(self.lable1.transform, M_PI);

self.lable2.center = CGPointMake(414/2, 736/2);

self.lable2.transform = CGAffineTransformRotate(self.lable2.transform, M_PI);

self.lable3.center = CGPointMake(414/2, 736/2);

self.lable3.transform = CGAffineTransformRotate(self.lable3.transform, M_PI);

self.lable4.center = CGPointMake(414/2, 736/2);

self.lable4.transform = CGAffineTransformRotate(self.lable4.transform, M_PI);

}];

//? ? ? ? [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.25 animations:^{

//

//? ? ? ? ? ? self.lable1.center = CGPointMake(354, 350);

//? ? ? ? ? ? self.lable1.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? ? ? self.lable2.center = CGPointMake(207, 200);

//? ? ? ? ? ? self.lable2.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? ? ? self.lable3.center = CGPointMake(60, 350);

//? ? ? ? ? ? self.lable3.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? ? ? self.lable4.center = CGPointMake(207, 500);

//? ? ? ? ? ? self.lable4.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? }];

//? ? ? ? [UIView addKeyframeWithRelativeStartTime:0.75 relativeDuration:0.25 animations:^{

//? ? ? ? ? ? self.lable1.center = CGPointMake(207, 200);

//? ? ? ? ? ? self.lable1.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? ? ? self.lable2.center = CGPointMake(60, 350);

//? ? ? ? ? ? self.lable2.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? ? ? self.lable3.center = CGPointMake(207, 500);

//? ? ? ? ? ? self.lable3.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? ? ? self.lable4.center = CGPointMake(354, 350);

//? ? ? ? ? ? self.lable4.transform = CGAffineTransformMakeRotation(M_PI);

//

//? ? ? ? }];

} completion:^(BOOL finished) {

}];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Core Animation Core Animation,中文翻譯為核心動畫,它是一組非常強大的動畫處理API,...
    45b645c5912e閱讀 3,164評論 0 21
  • 轉(zhuǎn)載:http://www.itdecent.cn/p/32fcadd12108 每個UIView有一個伙伴稱為l...
    F麥子閱讀 6,595評論 0 13
  • >*很不幸,沒人能告訴你母體是什么,你只能自己體會* --駭客帝國 在第四章“可視效果”中,我們研究了一些增強圖層...
    夜空下最亮的亮點閱讀 1,732評論 0 2
  • 有一個國家很神奇,它是世界上最窮的國家,卻是幸福指數(shù)最高的國家。在這個國家里,一年有300多個大小節(jié)日,一個人可以...
    脫俗兒閱讀 373評論 0 1
  • 很多人都有情人,而且不止一個。不同時期,或者同時擁有很多個??墒情L久的卻不多。為什么?有人說,玩夠了,和愛人一樣,...
    一休茶館閱讀 3,234評論 0 0

友情鏈接更多精彩內(nèi)容