iOS中动画(一)——UIView的动画
来源:互联网 发布:淘宝卖家不发货会怎样 编辑:程序博客网 时间:2024/05/16 00:46
iOS中UIView的动画
ViewController1.h
#import <UIKit/UIKit.h>@interface ViewController1 : UIViewController@property(nonatomic,retain)UIView* view1;@endViewController1.m
#import "ViewController1.h"@interface ViewController1 ()@end@implementation ViewController1- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self;}- (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view. _view1 = [[UIView alloc]init]; _view1.frame = CGRectMake(0, 44, 160, 200); _view1.backgroundColor = [UIColor redColor]; [self.view addSubview:_view1]; //过度动画的效果,是2个View的切换 UIButton* button2 = [[UIButton alloc]initWithFrame:CGRectMake(20, 340, 150, 30)]; [button2 addTarget:self action:@selector(button2) forControlEvents:UIControlEventTouchUpInside]; [button2 setTitle:@"开始动画" forState:UIControlStateNormal]; button2.backgroundColor = [UIColor redColor]; [self.view addSubview:button2];}-(void)button2{ // 1 传统方法 //开始动画 /*[UIView beginAnimations:@"testanimation" context:nil]; [UIView setAnimationDuration:0.5]; //动画的代理 [UIView setAnimationDelegate:self]; //动画的响应事件,使视图自动回到原来的位置 [UIView setAnimationDidStopSelector:@selector(animationstop)]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; //获得视图的位置 CGRect frames = self.view1.frame; //将坐标移到右边160处 frames.origin.x = 160; self.view1.frame = frames; [UIView commitAnimations];*/ // 2 用block语法实现 [UIView animateWithDuration:0.5 animations:^{ CGRect frames = self.view1.frame; frames.origin.x = 160; self.view1.frame = frames; //缩放 self.view1.transform = CGAffineTransformScale(self.view1.transform, 0.01, 0.01); }completion:^(BOOL finished) { CGRect frames = self.view1.frame; frames.origin.x = 0; self.view1.frame = frames; //恢复到原始的缩放 self.view1.transform = CGAffineTransformIdentity; }]; }-(void)animationstop{ //传统方法 [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; CGRect frames = self.view1.frame; frames.origin.x = 0; self.view1.frame = frames; [UIView commitAnimations];}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
2 0
- iOS中动画(一)——UIView的动画
- iOS中动画(一)——UIView的动画
- iOS 动画总结—UIView动画
- iOS—— UIView 动画
- iOS动画技术——UIView动画(视图动画)
- iOS动画—UIView动画以及CoreAnimation动画
- IOS中UIView动画的简单实现
- iOS动画 UIView动画
- iOS 动画 UIView动画
- ios uiview的动画效果
- iOS - UIView动画的使用方法
- iOS之UIView的动画
- iOS开发UI篇—核心动画(UIView封装动画)
- iOS开发UI篇—核心动画(UIView封装动画)
- iOS开发UI篇—核心动画(UIView封装动画)
- iOS开发UI篇—核心动画(UIView封装动画)
- iOS开发UI篇—核心动画(UIView封装动画)
- iOS开发UI篇—核心动画(UIView封装动画)
- 软考之排序算法(一)——插入排序
- course 5 6 knapsack
- 深入理解Image.createImage()
- java.lang.nullpointerexception 问题
- 微软2014实习生及秋令营技术类职位在线测试 题目1 : String reorder
- iOS中动画(一)——UIView的动画
- 今天累累的
- 一般排序组合
- boost::asio学习之[一]
- VS2008配置PC Lint (静态代码检查工具PC-Lint)
- C++实现单例方法
- 求职面试-算法复习系列
- 上传 Mac App 的图文教程
- Openflow简介和安装