IOS各种简单动画的实现
来源:互联网 发布:unity3d场景下载 编辑:程序博客网 时间:2024/06/01 09:41
#import "ViewController.h"
#import "aaViewController.h"
@interfaceViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *magentaView = [[UIViewalloc]initWithFrame:self.view.bounds];
magentaView.backgroundColor = [UIColormagentaColor];
[self.viewaddSubview:magentaView];
UIView *grayView = [[UIViewalloc]initWithFrame:self.view.bounds];
grayView.backgroundColor = [UIColorlightGrayColor];
[self.viewaddSubview:grayView];
NSArray *bnTitleArray = [NSArrayarrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",nil];
NSMutableArray *bnArray = [[NSMutableArrayalloc]init];
CGFloat totalHeight = [UIScreenmainScreen].bounds.size.height;
for (int i =0; i<8; i++) {
UIButton *bn = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
[bnsetTitle:[bnTitleArray objectAtIndex:i]forState:UIControlStateNormal];
NSInteger row = i/4;
NSInteger col = i%4;
bn.frame =CGRectMake(5+col*80,totalHeight-(2-row)*45-20,70,35);
[self.viewaddSubview:bn];
[bnArray addObject:bn];
}
[[bnArrayobjectAtIndex:0]addTarget:selfaction:@selector(add:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:1]addTarget:selfaction:@selector(curl:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:2]addTarget:selfaction:@selector(move:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:3]addTarget:selfaction:@selector(reveal:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:4]addTarget:selfaction:@selector(cube:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:5]addTarget:selfaction:@selector(suck:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:6]addTarget:selfaction:@selector(oglFlip:)forControlEvents:UIControlEventTouchUpInside];
[[bnArrayobjectAtIndex:7]addTarget:selfaction:@selector(ripple:)forControlEvents:UIControlEventTouchUpInside];
}
-(void)add:(id)sender
{
//开始执行动画
[UIViewbeginAnimations:@"animation"context:nil];
[UIViewsetAnimationDuration:1.0f];
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlDownforView:self.viewcache:YES];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.viewexchangeSubviewAtIndex:3withSubviewAtIndex:2];
[UIViewcommitAnimations];
}
-(void)curl:(id)sender
{
//开始执行动画
[UIViewbeginAnimations:@"animation"context:nil];
[UIViewsetAnimationDuration:1.0f];
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUpforView:self.viewcache:YES];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.viewexchangeSubviewAtIndex:3withSubviewAtIndex:2];
[UIViewcommitAnimations];
}
-(void)move:(id)sender
{
CATransition *transition = [CATransitionanimation];
transition.duration =2.0f;
transition.type =kCATransitionMoveIn;
transition.subtype =kCATransitionFromLeft;
[self.view.layeraddAnimation:transition forKey:@"animation"];
[self.viewexchangeSubviewAtIndex:2withSubviewAtIndex:3];
}
-(void)reveal:(id)sender
{
CATransition *transition = [CATransitionanimation];
transition.duration =2.0f;
transition.type =kCATransitionReveal;
transition.subtype =kCATransitionFromTop;
[self.view.layeraddAnimation:transition forKey:@"animation"];
[self.viewexchangeSubviewAtIndex:2withSubviewAtIndex:3];
}
-(void)cube:(id)sender
{
CATransition *transition = [CATransitionanimation];
transition.duration =2.0f;
transition.type =@"cube";
transition.subtype =kCATransitionFromLeft;
[self.view.layeraddAnimation:transition forKey:@"animation"];
[self.viewexchangeSubviewAtIndex:2withSubviewAtIndex:3];
}
-(void)suck:(id)sender
{
CATransition *transition = [CATransitionanimation];
transition.duration =2.0f;
transition.type =@"suckEffect";
// transition.subtype = kCATransitionFromLeft;
[self.view.layeraddAnimation:transition forKey:@"animation"];
[self.viewexchangeSubviewAtIndex:2withSubviewAtIndex:3];
}
-(void)oglFlip:(id)sender
{
CATransition *transition = [CATransitionanimation];
transition.duration =2.0f;
transition.type =@"oglFlip";
transition.subtype =kCATransitionFromBottom;
[self.view.layeraddAnimation:transition forKey:@"animation"];
[self.viewexchangeSubviewAtIndex:2withSubviewAtIndex:3];
}
-(void)ripple:(id)sender
{
//水波滑动
[UIViewanimateWithDuration:4.0animations:^{
CATransition *transition = [CATransitionanimation];
transition.duration =4.0f;
transition.type =@"rippleEffect";
[self.view.layeraddAnimation:transition forKey:@"animation"];
transition.delegate =self;
[self.view.layeraddAnimation:transition forKey:nil];
} completion:^(BOOL finished){
[NSTimertimerWithTimeInterval:2.0target:selfselector:@selector(timee:)userInfo:nilrepeats:NO];
}];
}
- IOS各种简单动画的实现
- ios简单动画的实现
- IOS中各种动画特效的实现
- iOS-实现简单的动画效果
- ios气泡动画效果的简单实现
- IOS中UIView动画的简单实现
- iOS简单的动画效果实现
- ios高级动画的简单实现
- IOS简单的动画
- ios 的简单动画
- iOS UIImageview实现简单动画
- iOS简单动画实现方案
- iOS 碎片动画简单实现
- 简单动画的实现
- iOS --用CABasicAnimation实现简单的动画效果
- ios平移与抖动动画的简单实现
- iOS 简单动画效果实现的三种方式
- iOS TableView给力动画的简单实现
- PostgreSQL pg_bulkload speed test
- lightoj 1044 - Palindrome Partitioning DP优化DP
- Docker初体验1 —几个概念的理解
- JAVA单聊模式的不同写法
- 为什么要三次握手
- IOS各种简单动画的实现
- Linux基础05_磁盘管理
- App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
- 泛型问题
- Android开发编程Fragment对象引出新功能
- 给未来程序员的15个顶级职业建议
- android之自定义UncaughtExceptionHandler类来处理未捕获异常
- IOS 提交审核如何勾选选项
- python函数里面的装饰器和闭包的理解