iOS UIView动画效果
2015-10-23 12:00
441 查看
1.普通动画:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
frame.origin.x += 150;
[img setFrame:frame];
[UIView commitAnimations];
2.连续动画(一系列图像):
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.png"], nil];
UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImage;
myAnimatedView.animationRepeatCount = 0;
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[my AnimatedView release];
3.CATransition Public API:
CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMide = KCAFillModeForwards;
//各种动画效果
/*
KCATransitionFade;
KCATransitionMoveIn;
KCATransitionPush;
KCATransitionReveal;
*/
/*
KCATransitionFromeRight;
KCATransitionFromLeft;
KCATransitionFormTop;
kCATransitionFromButtons;
*/
//各种组合
animation.type = KCATransitionPush;
animation.subtype = KCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:@"animation"];
4.UIView Animations动画:
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.5f]
4000
;
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
//以下四种效果
/*
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormLeft forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormRight forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
*/
5.嵌套使用,先变大再消失
[UIView animateWithDuration:1.25 aniamtions:^{
CGAffineTransform newTRansform = CGAffineTransformMakeScale(1.2, 1.2);
[firstImageView setTransform:newTransform];
[secondImageView setTransform:newTransform];
completion:^(BOOL finished){
[UIView animateWithDuration:1.2 animations:^{
[firstImageView setAlpha:0];
[secondImageView setAlpha:0];
}
completion:^(BOOL finished){
[firstImageView removeFromSuperview];
[secondImageView removeFromSuperview];
}
];
}
];
----------------------------------
All animation name of LayerKit in iPhone:
oglFlip // flip in Stocks
pageCurl // page animation in Notes
pageUnCurl // reverse of pageCurl
suckEffect // delete animation in Notes
spewEffect // reverse of suckEffect
genieEffect // minimize effect like in MacOSX
unGenieEffect // reverse of genieEffect
twist // flip the page in twist style
tubey // flip the page in tube style
swirl // swirl effect
rippleEffect // ripple effect
cameraIris // take photo effect in Camera
cameraIrisHollow //
cameraIrisHollowOpen // apeature open effect
cameraIrisHollowClose // apeature close effect
charminUltra // wash out and then return to normal
reflection //
zoomyIn // zoomin, fade in transition
zoomyOut // zoom out, fade in transition
oglApplicationSuspend //quit program zoom out effect
mapCurl // Maps page flip up effect
mapUnCurl // maps page flip down effect
Note that except oglFlip, other transition effect not work under simulator, and simple fade in/out will be used instead. But it actually works on the real device.
声明:OSCHINA 博客文章版权属于作者 转载于ios开发者社区
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
frame.origin.x += 150;
[img setFrame:frame];
[UIView commitAnimations];
2.连续动画(一系列图像):
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.png"], nil];
UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImage;
myAnimatedView.animationRepeatCount = 0;
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[my AnimatedView release];
3.CATransition Public API:
CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMide = KCAFillModeForwards;
//各种动画效果
/*
KCATransitionFade;
KCATransitionMoveIn;
KCATransitionPush;
KCATransitionReveal;
*/
/*
KCATransitionFromeRight;
KCATransitionFromLeft;
KCATransitionFormTop;
kCATransitionFromButtons;
*/
//各种组合
animation.type = KCATransitionPush;
animation.subtype = KCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:@"animation"];
4.UIView Animations动画:
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.5f]
4000
;
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
//以下四种效果
/*
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormLeft forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormRight forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
*/
5.嵌套使用,先变大再消失
[UIView animateWithDuration:1.25 aniamtions:^{
CGAffineTransform newTRansform = CGAffineTransformMakeScale(1.2, 1.2);
[firstImageView setTransform:newTransform];
[secondImageView setTransform:newTransform];
completion:^(BOOL finished){
[UIView animateWithDuration:1.2 animations:^{
[firstImageView setAlpha:0];
[secondImageView setAlpha:0];
}
completion:^(BOOL finished){
[firstImageView removeFromSuperview];
[secondImageView removeFromSuperview];
}
];
}
];
----------------------------------
All animation name of LayerKit in iPhone:
oglFlip // flip in Stocks
pageCurl // page animation in Notes
pageUnCurl // reverse of pageCurl
suckEffect // delete animation in Notes
spewEffect // reverse of suckEffect
genieEffect // minimize effect like in MacOSX
unGenieEffect // reverse of genieEffect
twist // flip the page in twist style
tubey // flip the page in tube style
swirl // swirl effect
rippleEffect // ripple effect
cameraIris // take photo effect in Camera
cameraIrisHollow //
cameraIrisHollowOpen // apeature open effect
cameraIrisHollowClose // apeature close effect
charminUltra // wash out and then return to normal
reflection //
zoomyIn // zoomin, fade in transition
zoomyOut // zoom out, fade in transition
oglApplicationSuspend //quit program zoom out effect
mapCurl // Maps page flip up effect
mapUnCurl // maps page flip down effect
Note that except oglFlip, other transition effect not work under simulator, and simple fade in/out will be used instead. But it actually works on the real device.
声明:OSCHINA 博客文章版权属于作者 转载于ios开发者社区
相关文章推荐
- GUI - Web前端开发框架
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 评价ui设计作品好坏的八个标准(界面/交互设计研究)
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 为Yahoo! UI Extensions Grid增加内置的可编辑器
- Cocos2d-x UI开发之文本类使用实例
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- UI Events 用户界面事件
- 基于jQuery UI CSS Framework开发Widget的经验
- jquery ui 1.7 ui.tabs 动态添加与关闭(按钮关闭+双击关闭)
- jQuery UI设置固定日期选择特效代码分享
- jQuery UI的Dialog无法提交问题的解决方法
- jQuery ui实现动感的圆角渐变网站导航菜单效果代码
- 关于jQuery UI 使用心得及技巧
- jQuery ui 1.7更新小结