IOS自带view动画效果
2012-07-21 09:36
387 查看
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];
[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.
[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];
[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.
相关文章推荐
- IOS自带view动画效果
- iOS动画--UIView自带动画效果、Block动画
- ios-计时器示范:一闪一闪View(动画效果)
- XZ_iOS之使用webView实现开机动画效果
- ios UIImageView添加图片动画效果,添加了手势之后,依然没有反应的解决方法
- ios view与view间切换的动画效果
- iOS开发UIImage和UIImageView属性介绍,实现图片动画,实现开始/停止按钮效果
- iOS开发导航控制器下不同视图控制器之间切换:利用CATrasition和view的layer层来实现自定义的动画效果
- ios 自定义弹出UIPickerView或UIDatePicker(动画效果)
- ios学习笔记---用View动画仿UC浏览器菜单栏弹出效果
- IOS开动画效果之──实现 pushViewController 默认动画效果(转)
- Android进阶——自定义View之继承系统控件实现自带删除按钮动画效果和软键盘自动悬浮于文本框下方
- Android自定义View之popupwindow进阶封装:高仿ios “item动画弹出”效果的popupwindow。
- [iOS]在tableview中用动画效果改变cell的高度
- IOS动画实现(2)ImageView自带动画
- uitable view自带的动画效果
- 【iOS开发】关于显示一连串图片组成动画效果UIImageView的使用
- IOS开动画效果之──实现 pushViewController 默认动画效果
- ios scrollView中增加动画效果,自动滚动UIScrollView,利用了NSTimer
- IOS开动画效果之──实现 pushViewController 默认动画效果