码迷,mamicode.com
首页 > 其他好文 > 详细

动画效果-基础动画设置(改变大小,改变透明度,翻转,旋转,复原)

时间:2016-05-19 23:17:53      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:

在可视化编程下

#import "BaseViewController.h"

@interface BaseViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation BaseViewController

- (void)viewDidLoad {

    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

}

// 改变大小

- (IBAction)changeSizeAction:(UIButton *)sender {

    // 开始设置动画

    [UIView beginAnimations:@"size" context:nil];

    // 动画时长

    [UIView setAnimationDuration:2];

    // 改变后的图片大小

    self.imageView.frame = CGRectMake(50, 80, 200, 200);

    // 提交动画,开始播放动画

    [UIView commitAnimations];

}

// 改变透明度

- (IBAction)changeAlpha:(UIButton *)sender {

    [UIView beginAnimations:@"alpha" context:nil];

    [UIView setAnimationDuration:2];

    self.imageView.alpha = 0.5;

    // 改变背景颜色

    self.imageView.backgroundColor = [UIColor cyanColor];

    [UIView commitAnimations];

}

// 翻转

- (IBAction)overturnAction:(UIButton *)sender {

    // 开始设置动画

    [UIView beginAnimations:@"fanzhuan" context:nil];

    // 动画时长

    [UIView setAnimationDuration:2];

    // 设置翻转

    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.imageView cache:YES];

    // 提交动画,开始播放动画

    [UIView commitAnimations];

}

// 旋转

- (IBAction)xuanzhuanAction:(UIButton *)sender {

    // 开始设置动画

    [UIView beginAnimations:@"xuanzhuan" context:nil];

    // 动画时长

    [UIView setAnimationDuration:2];

    // 设置旋转角度

    // 参数1:当前的transform  参数2:旋转弧度

    CGAffineTransform transform = CGAffineTransformRotate(self.imageView.transform, M_PI_2);

    // 设置旋转

    [self.imageView setTransform:transform];

    // 提交动画,开始播放动画

    [UIView commitAnimations];

}

// 复原

- (IBAction)fuyuanAction:(UIButton *)sender {

    // 开始设置动画

    [UIView beginAnimations:@"xuanzhuan" context:nil];

    // 动画时长

    [UIView setAnimationDuration:2];

    // 设置旋转角度(0度和180度不变,其它值相反)

    // 参数1:当前的transform  参数2:旋转弧度

    CGAffineTransform transform = CGAffineTransformInvert(self.imageView.transform);

    // 设置旋转

    [self.imageView setTransform:transform];

    // 提交动画,开始播放动画

    [UIView commitAnimations];

}

 

/*

#pragma mark - Navigation

 

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/

@end

 

动画效果-基础动画设置(改变大小,改变透明度,翻转,旋转,复原)

标签:

原文地址:http://www.cnblogs.com/Mr-zyh/p/5510323.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!