IOS之基础动画
来源:互联网 发布:编码器编程程序接线图 编辑:程序博客网 时间:2024/05/18 00:43
//
// ViewController.m
// 基础动画
//
// Created by 李江 on 16/5/12.
// Copyright © 2016年李江. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *view1 = [[UIViewalloc]initWithFrame:self.view.frame];
view1.tag =200;
view1.backgroundColor = [UIColorredColor];
[self.viewaddSubview:view1];
UIView *view2 = [[UIViewalloc]initWithFrame:self.view.frame];
view2.backgroundColor = [UIColorgrayColor];
view2.tag =100;
[self.viewaddSubview:view2];
}
//触摸屏幕时调用
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[selfblockxchangeView];
}
//转场动画
-(void)exchangeView{
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationCurve:UIViewAnimationCurveLinear];
[UIViewsetAnimationDuration:1.5];
//设置转场效果
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUpforView:self.viewcache:YES];
//实现转场
UIView *view1 = [self.viewviewWithTag:200];
UIView *view2 = [self.viewviewWithTag:100];
NSInteger indexOfview1 = [self.view.subviewsindexOfObject:view1];
NSInteger indexOfview2 = [self.view.subviewsindexOfObject:view2];
[self.viewexchangeSubviewAtIndex:indexOfview1withSubviewAtIndex:indexOfview2];
[UIViewcommitAnimations];
}
//block方式的转场动画
-(void)blockBaseAnimation{
UIView *view2 = [self.viewviewWithTag:100];
[UIViewanimateWithDuration:2animations:^{
view2.alpha =0.2;
}completion:^(BOOL finished) {
[UIViewanimateWithDuration:2animations:^{
view2.alpha =1;
}];
}];
}
//另一种block方式的专场动画
-(void)blockxchangeView{
[UIViewtransitionWithView:self.viewduration:2options:UIViewAnimationOptionTransitionFlipFromLeftanimations:^{
[self.viewexchangeSubviewAtIndex:2withSubviewAtIndex:3];
} completion:^(BOOL finished) {
}];
}
//基础动画之缩小篇
-(void)baseAnimation{
//开始动画
[UIViewbeginAnimations:@"view1"context:@"缩小"];
//设置动画加速方式
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
//动画时长
[UIViewsetAnimationDuration:2.0];
//设置代理
[UIViewsetAnimationDelegate:self];
//指定动画结束时执行的方法
[UIViewsetAnimationDidStopSelector:@selector(animationDidStop:finished:)];
UIView *view2 = [self.viewviewWithTag:100];
CGRect rect = view2.frame;
rect.size =CGSizeMake(100,100);
view2.frame = rect;
view2.center =self.view.center;
}
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- IOS之基础动画
- iOS程序猿之iOS动画基础
- iOS动画-基础动画
- IOS疯狂基础之-动画Animations
- iOS讲解迷惑深入浅出之基础动画-关键帧动画
- iOS核心动画----基础动画
- iOS 核心动画-基础动画
- iOS 核心动画 -基础动画
- ios 动画基础
- ios 动画基础
- ios 动画基础
- ios 动画基础
- 关于 iOS 基础动画
- ios 动画基础
- ios 动画函数基础
- iOS基础动画
- iOS 动画基础
- iOS动画组基础
- ubuntu软件源更新及其中会遇到的各种问题(以下ID的密钥没有可用的公钥)
- 用PHP开发购物车网站(第三篇):零碎知识(1)
- hdu4587TWO NODES【割点】
- Dockerizing a Node.js web app
- easyui combotree加载静态前台json问题
- IOS之基础动画
- 2014年最热门的国人开发开源软件TOP100
- MS SQL Server:分区表、分区索引 详解
- android环境搭建
- 防刷新,只有关闭浏览器才会增加点击量
- Caffe研究实践 四 -------lenet_train_test.prototxt分析
- Linux上JDK的安装和卸载
- qt tableb view 打印预览和打印的问题 个人解决办法
- AsyncTask 异步加载网络图片简单应用