国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > iOS > 正文

IOS 開(kāi)發(fā)之UIView動(dòng)畫(huà)的實(shí)例詳解

2019-10-21 18:45:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

IOS 動(dòng)畫(huà)實(shí)例詳解

iOS動(dòng)畫(huà)的實(shí)現(xiàn)方式多種多樣,這里就只記錄一下 beginAnimations:context 。

在你調(diào)用 beginAnimations:context:方法來(lái)啟動(dòng)一個(gè)動(dòng)畫(huà)后,動(dòng)畫(huà)并不會(huì)立即被執(zhí)行,直 到你調(diào)用 UIView 類(lèi)的 commitAnimations 類(lèi)方法。你對(duì)一個(gè)視圖對(duì)象執(zhí)行的介于 beginAnimations:context:方法跟 commitAnimations方法之間的操作(例如移動(dòng))會(huì)在 commitAnimations 被執(zhí)行后才會(huì)生效 。

實(shí)現(xiàn)效果圖:

IOS,UIView動(dòng)畫(huà),動(dòng)畫(huà),UIViewIOS,UIView動(dòng)畫(huà),動(dòng)畫(huà),UIView

代碼很簡(jiǎn)單,直接貼了,如下:

// // ViewController.m // Graphics // // Created by aaron on 14b-5-29. // Copyright (c) 2014年 The Technology Studio. All rights reserved. //  #import "ViewController.h"  @interface ViewController () @property(nonatomic,strong) UIImageView *imageView1; @property(nonatomic,strong) UIImageView *imageView2;  @end  @implementation ViewController  - (void)viewDidLoad {   [super viewDidLoad];      UIImage *image = [UIImage imageNamed:@"1.png"];   self.imageView1 = [[UIImageView alloc] initWithImage:image];   self.imageView2 = [[UIImageView alloc] initWithImage:image];   [self.imageView1 setFrame:CGRectMake(0.0f,                      0.0f,                      100.0f,                      100.0f)];      [self.imageView2 setFrame:CGRectMake(220.0f,                      350.0f,                      100.0f,                      100.0f)];   [self.view addSubview:self.imageView1];   [self.view addSubview:self.imageView2];    //  [self startTopLeftImageViewAnimation]; //  [self startBottomRightViewAnimationAfterDelay:2];   [self affineTransformScaleAnimation];   [self affineTransformRotateAnimation];    }  //imageView2 animation -(void)startTopLeftImageViewAnimation{   [self.imageView1 setFrame:CGRectMake(0.0f,                      0.0f,                      100.0f,                      100.0f)];   [self.imageView1 setAlpha:1.0f];   [UIView beginAnimations:@"imageView1Animation" context:(__bridge void*)self.imageView1];   [UIView setAnimationDuration:3.0f];   [UIView setAnimationDelegate:self];   [UIView setAnimationDidStopSelector:@selector(imageViewDidStop:finished:context:)];   [self.imageView1 setFrame:CGRectMake(220.0f, 350.0f, 100.0f, 100.0f)];   [self.imageView1 setAlpha:0.0f];   [UIView commitAnimations]; }  -(void)imageViewDidStop:(NSString*)paramAnimationID finished:(NSNumber*)paramFinished context:(void*)paramContext{   NSLog(@"AnimationID = %@/n",paramAnimationID);   UIImageView *contextImageView = (__bridge UIImageView *)(paramContext);   NSLog(@"contextImageView = %@",contextImageView);   [contextImageView removeFromSuperview]; }   //imageView2 animation -(void)startBottomRightViewAnimationAfterDelay:(CGFloat)paramDelay{   [self.imageView2 setFrame:CGRectMake(220.0f,                      350.0f,                      100.0f,                      100.0f)];   [self.imageView2 setAlpha:1.0f];   [UIView beginAnimations:@"imageView2Animation" context:(__bridge voidvoid *)(self.imageView2)];   [UIView setAnimationDuration:3.0f];   [UIView setAnimationDelay:paramDelay];   [UIView setAnimationDelegate:self];   [UIView setAnimationDidStopSelector:@selector(imageViewDidStop:finished:context:)];   [self.imageView2 setFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];   [self.imageView2 setAlpha:0.0f];   [UIView commitAnimations]; }   //imageView1 AffineTransformScale animation -(void)affineTransformScaleAnimation{   self.imageView1.center = self.view.center;   self.imageView1.transform = CGAffineTransformIdentity;   [UIView beginAnimations:nil context:NULL];   [UIView setAnimationDuration:5.0f];   self.imageView1.transform = CGAffineTransformMakeScale(2.0f, 2.0f);   [self.imageView1 setAlpha:0.0f];   [UIView commitAnimations]; }  //imageView2 AffineTransformRotate animation -(void)affineTransformRotateAnimation{   self.imageView2.center = self.view.center;   [UIView beginAnimations:@"clockwiseAnimation" context:NULL];   [UIView setAnimationDuration:5.0f];   [UIView setAnimationDelegate:self];   [UIView setAnimationDidStopSelector:@selector(clockwiseRotationStopped:finished:context:)];   self.imageView2.transform = CGAffineTransformMakeRotation(90.0f*M_PI/180.f);   [UIView commitAnimations]; }   -(void)clockwiseRotationStopped:(NSString*)paramAnimationID finished:(NSNumber*)paramFinished context:(void*)paramContext{   [UIView beginAnimations:@"counterclockwiseAnimation" context:NULL];   [UIView setAnimationDuration:5.0f];   self.imageView2.transform = CGAffineTransformIdentity;   [UIView commitAnimations]; }  @end 

以上就是關(guān)于IOS動(dòng)畫(huà)開(kāi)發(fā)的實(shí)例,本站對(duì)于IOS 開(kāi)發(fā)還有很多教程,大家可以搜索查閱!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到IOS開(kāi)發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 鹤庆县| 米林县| 庐江县| 同德县| 合阳县| 叶城县| 定州市| 鄄城县| 藁城市| 遂溪县| 泽库县| 古丈县| 禹州市| 兴化市| 台北县| 临澧县| 盘锦市| 仁寿县| 古田县| 清水河县| 泽普县| 阿克| 巫溪县| 上饶县| 桃江县| 平潭县| 三门县| 莆田市| 柘城县| 永济市| 英超| 达尔| 株洲县| 正镶白旗| 东丰县| 仁化县| 大埔区| 义乌市| 湘潭县| 南木林县| 博野县|