如何取消UIAlertView的tableview动画效果闪屏效果

解决导航栏推出一个透明的视图控制器闪屏的问题 - 简书
解决导航栏推出一个透明的视图控制器闪屏的问题
随便百度一下,发现答案千篇一律,所谓把backgroudColor改成不透明就可以了,但如果需求一定要透明呢?首先我们创建一个类TransitionAnimator,集成NSObject,并遵循&UIViewControllerAnimatedTransitioning&代理,记得要引入&UIKit/UIKit.h&。在TransitionAnimator.h里申明一个bool类型的属性@property(nonatomic,assign,getter= isPresenting) BOOL用此属性帮我们判断是导航栏push还是pop。在TransitionAnimator.m文件里写所遵循协议里的两个代理,一个是动画时间,一个是动画内容。
- (NSTimeInterval)transitionDuration:(id)transitionContext {
return0.5f; //返回动画时间
- (void)animateTransition:(id)transitionContext{
//获取推走的控制器以及推出的控制器
UIViewController *fromVC = [transitionContextviewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContextviewControllerForKey:UITransitionContextToViewControllerKey];
if(self.presenting) {
//如果是push动作的话
//先把view放进容器里
[transitionContext.containerView addSubview:fromVC.view];
[transitionContext.containerView addSubview:toVC.view];
//设置基本参数,设置目的控制器在源控制器的左边
toVC.view.frame=CGRectMake(fromVC.view.frame.size.width,0, fromVC.view.frame.size.width, toVC.view.frame.size.height);
[UIViewanimateWithDuration:[selftransitionDuration:transitionContext]
animations:^{
//源控制器推出窗口
fromVC.view.frame=CGRectMake(-fromVC.view.frame.size.width,0, fromVC.view.frame.size.width, fromVC.view.frame.size.height);
toVC.view.frame=CGRectMake(0,0, toVC.view.frame.size.width, toVC.view.frame.size.height);
}completion:^(BOOLfinished) {
[transitionContextcompleteTransition:YES];
//如果是pop动作的话
[transitionContext.containerViewaddSubview:fromVC.view];
[transitionContext.containerViewaddSubview:toVC.view];
toVC.view.frame=CGRectMake(-toVC.view.frame.size.width,0, toVC.view.frame.size.width, toVC.view.frame.size.height);
[UIViewanimateWithDuration:[selftransitionDuration:transitionContext]
animations:^{
fromVC.view.frame=CGRectMake(toVC.view.frame.size.width,0, fromVC.view.frame.size.width, fromVC.view.frame.size.height);
toVC.view.frame=CGRectMake(0,0, toVC.view.frame.size.width, toVC.view.frame.size.height);
}completion:^(BOOLfinished) {
[transitionContextcompleteTransition:YES];
在你要执行推出的视图控制器里,导入TransitionAnimator.h这个文件,导入代理&UINavigationControllerDelegate&在此控制器里增加以下代码
- (void)viewDidAppear:(BOOL)animated{
self.navigationController.delegate=
[super viewDidAppear:animated];
- (void)viewDidDisappear:(BOOL)animated{
if(self.navigationController.delegate==self) {
self.navigationController.delegate=
[super viewDidDisappear:animated];
并添加代理方法,在代理方法里创建一个TransitionAnimator类的对象,并返回这个对象即可
- (id)navigationController: (UINavigationController*)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController*)fromVC toViewController:(UIViewController*)toVC{
TransitionAnimator *animator = [TransitionAnimator new];
animator.presenting=YES;
在你要pop的viewController里也添加push视图控制器里一模一样的代码,只不过把animator.presenting = NO;即可这样push和pop都不会出现推出透明的view闪屏的烦人东西了。效果图:
我设定的是点击click按钮push下一页
推出后到FViewCOntroller
效果就是我点击Menu,从右侧推出一个视图控制器,但是我仍然可以看到主Controller的view上的字,点击click按钮,推出FViewController,仍然可以看到主Controller的view上的字,而且向右push,向左pop不会有闪屏的问题,动画效果也在。当然你也可以自定义推出动画,改变&UIViewControllerAnimatedTransitioning&代理里第二个代理方法里的fromVC和toVC的frame即可,也可以添加一些3D效果。此外,在代理方法里可以用operation来判断是push还是pop。下次自动登录
现在的位置:
& 综合 & 正文
Android实现闪屏渐入渐出效果实例
package com.oschina.
import android.app.A
import android.content.I
import android.os.B
import android.util.L
import android.view.V
import android.view.animation.AlphaA
import android.view.animation.A
import android.view.animation.Animation.AnimationL
public class SplashActivity extends Activity{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final View view = View.inflate(this, R.layout.splash, null);
setContentView(view);
//渐变展示启动屏
AlphaAnimation aa = new AlphaAnimation(0.3f,1.0f);
aa.setDuration(2000);
view.startAnimation(aa);
aa.setAnimationListener(new AnimationListener()
public void onAnimationEnd(Animation arg0) {
redirectTo();
Log.i("log", "触发了事件");
public void onAnimationRepeat(Animation animation) {}
public void onAnimationStart(Animation animation) {}
* 跳转到主的
private void redirectTo(){
Intent intent = new Intent(this, Main.class);
startActivity(intent);
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/welcome"&
&/LinearLayout&
变化结束后触发了日志事件
&&&&推荐文章:
【上篇】【下篇】
<a href="/zt/.html" title="jquery 的jquery 的<asp的控件1.保证程序UI和设计图完全吻合(UI显示)
2.尽量能避免闪出闪去等操作,结合实际情况,能过渡的交互尽量结合动画制作,以符合ios风&#26684;,(Animation)
(一).UI显示:
原则:保证要与设计图模式一摸一样,发现不适合的东西,需要及时沟通后让设计师修改,尽量要保证和设计图的像素一一对应
1.自定义UIAlertView:
UIAlertView
*theAlert = [[UIAlertView alloc] initWithTitle:title message:message
delegate:delegate cancelButtonTitle:cancleTitle
otherButtonTitles:otherTitle,nil];
[theAlert show];
theAlert.backgroundColor = [UIColor clearColor];
UILabel *theTitle = [theAlert valueForKey:@&_titleLabel&];
[theTitle setTextColor:[UIColor whiteColor]];
UILabel *theBody = [theAlert valueForKey:@&_bodyTextLabel&];
[theBody setTextColor:[UIColor whiteColor]];
UIImage *theImage = [UIImage imageNamed:@&alertBack.png&];
theImage = [theImage stretchableImageWithLeft&wbr&CapWidth:0.
topCapHeight:0.];
CGSize theSize = [theAlert frame].
UIGraphicsBeginImageCont&wbr&ext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCu&wbr&rrentImageContext();
UIGraphicsEndImageContex&wbr&t();
theAlert.layer.contents = (id)[theImage CGImage];
for (UIView *tempView in theAlert.subviews)
if ([tempView isMemberOfClass:[UIImageView class]])
[tempView removeFromSuperview];
[theAlert release];
UIAlertView*theAlert =[[UIAlertView
alloc] initWithTitle:title
message:message delegate:delegate
cancelButtonTitle:cancleTitle otherButtonTitles:otherTitle,nil];
[theAlertshow];
theAlert.backgroundColor =
[UIColor clearColor];
UILabel *theTitle= [theAlert
valueForKey:@&_titleLabel&];
[theTitle setTextColor:[UIColor
whiteColor]];
UILabel *theBody= [theAlert
valueForKey:@&_bodyTextLabel&];
[theBody setTextColor:[UIColor
whiteColor]];
UIImage *theImage= [UIImage
imageNamed:@&alertBack.png&];
theImage = [theImage
stretchableImageWithLeftCapWidth:0.topCapHeight:0.];
CGSize theSize= [theAlert
frame].size;
UIGraphicsBeginImageContext(theSize);
[theImagedrawInRect:CGRectMake(0,0,
theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
theAlert.layer.contents
= (id)[theImage
for (UIView *tempView
in theAlert.subviews)
if([tempView isMemberOfClass:[UIImageView
[tempViewremoveFromSuperview];
[theAlert release];
class=&Apple-style-span& style=&font-family: Georgia, 'Times New
Roman', 'Bitstream Charter', Times, font-size: 13 line-height:
19 white-space:&&2.自定义UIPageControl&/span&
&span class=&Apple-style-span&
style=&font-family: Georgia, 'Times New Roman', 'Bitstream Charter',Times, font-size: 13 line-height: 19 white-space:&&2.自定义UIPageControl&/span&
改变点儿的颜色,可以改变小点儿的颜色:(附件中)
MyPageControl.h
MyPageControl.m
3.自定义UISegmentConrol
改变自定义风&#26684;:(需要用切图配合)
UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:
[UIImage imageNamed:@&seg1_tapped.png&],
[UIImage imageNamed:@&seg2.png&],
[UIImage imageNamed:@&seg3.png&],nil]];
segmentControl.segmentedControlStyle = UISegmentedControlStyleB&wbr&
segmentControl.frame = CGRectMake((DeviceWidth-76*3)/2-9, 14+[cellContentArray count]*35, 76*3, 33.5);
segmentControl.selectedSegmentIndex = 0;
[segmentControl addTarget:self action:@selector(changeBookType:) forControlEvents:UIControlEventValueChang&wbr&ed];
[cell.contentView addSubview:segmentControl];
[segmentControl release];
UISegmentedControl *segmentControl =
[[UISegmentedControl alloc]
initWithItems:[NSArray
arrayWithObjects:
[UIImageimageNamed:@&seg1_tapped.png&],
[UIImage imageNamed:@&seg2.png&],
[UIImageimageNamed:@&seg3.png&],nil]];
segmentControl.segmentedControlStyle
=UISegmentedControlStyleBar;
segmentControl.frame =CGRectMake((DeviceWidth-76*3)/2-9,14&#43;[cellContentArray
count]*35,76*3,
segmentControl.selectedSegmentIndex
[segmentControladdTarget:self
action:@selector(changeBookType:)
forControlEvents:UIControlEventValueChanged];
[cell.contentView
addSubview:segmentControl];
[segmentControlrelease];
4.自定义UIProgressView
改变pressView的进度颜色显示:基于QuartzCore绘制图像
CustemProgressBar.h
CustemProgressBar.m
5.自定义UITableView/UITableViewCell
很常用,往后要倾向IB来做:layOutSubView布局frame
6.自定义UINavigationBar(用view组合)
TopBarView.h
TopBarView.m
我的做法:将自身的navibar英藏后在显示为自定义的navibarView:这样方便程序来控制:
7.自定义UIPopViewController(用view组合)
iPhone里不支持PopViewController,但是有时会需要在程序里显示PopViewController这样的东西
8.自定义UITabBarView
用一组button组合成tabbar的显示,方便灵活,但要确保需要管理好内容:
由于sdk中的tabbar是很不灵活的,隐藏之类的操作都很难控制:
9.自定义UISearchBar
用多个view组合起来平城searchview的显示:可以改变背景,圆角等
改变背景等需求;
10.自定义UITextField/UITextView
可以换背景等:leftview rightView background等
11.翻页效果:UIPageViewController(iOS5)
1.官方demo,
2.leaves框架翻页效果
(二).常用到的动画汇总:
一.控件本身附有的动画方法:
UIKit包含的动画效果,用起来也比较省事,举例如下:
1. [self.navigationController setNavigationBarHidden:YESanimated:YES];
2.一般使用UITableView的的动画效果汇总:
先设置数据源,然后在执行动画:
An errorhas occurred. Please try again later.
(void)insertSections:(NSIndexSet *)sections
withRowAnimation:(UITableViewRowAnimation)
- (void)deleteSections:(NSIndexSet *)sections
withRowAnimation:(UITableViewRowAnimation)
- (void)reloadSections:(NSIndexSet *)sections
withRowAnimation:(UITableViewRowAnimation)animation
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)animation
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
-(void)insertSections:(NSIndexSet*)sectionswithRowAnimation:(UITableViewRowAnimation)animation;
- (void)deleteSections:(NSIndexSet *)sections
withRowAnimation:(UITableViewRowAnimation)animation;
-(void)reloadSections:(NSIndexSet*)sectionswithRowAnimation:(UITableViewRowAnimation)animation
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
- (void)insertRowsAtIndexPaths:(NSArray*)indexPathswithRowAnimation:(UITableViewRowAnimation)animation;
-(void)deleteRowsAtIndexPaths:(NSArray*)indexPathswithRowAnimation:(UITableViewRowAnimation)animation;
- (void)reloadRowsAtIndexPaths:(NSArray*)indexPathswithRowAnimation:(UITableViewRowAnimation)animation
__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
3.[scrollVie setContentOffset:CGPoint animated:BOOL]
4.UIImageView的动画效果:
UIImageView *campFireView = [[UIImageView alloc] initWithFrame:XXX];
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@&campFire01.gif&],
[UIImage imageNamed:@&campFire02.gif&]......., nil];
campFireView.animationDuration = 1.75;
campFireView.animationRepeatCount = 0;
[campFireView startAnimating];
[campFireView release];
UIImageView*campFireView = [[UIImageView
alloc] initWithFrame:XXX];
campFireView.animationImages =
[NSArray arrayWithObjects:
[UIImage imageNamed:@&campFire01.gif&],
[UIImageimageNamed:@&campFire02.gif&].......,
campFireView.animationDuration
campFireView.animationRepeatCount=
[campFireView startAnimating];
[campFireViewrelease];
二.UIViewAnimation实例:Animation块动画,Animation块支持多种动画叠加,会产生各种不同的效果
//在这里之前初始化参数
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:delegate];
[UIView setAnimationWillStartSel&wbr&ector:startSelector];//开始的代理
[UIView setAnimationDidStopSelec&wbr&tor:stopSelector];//结束的代理
[UIView setAnimationDuration:seconds];
[UIView beginAnimations:nil
context:nil];
[UIView setAnimationDelegate:delegate];
[UIView setAnimationWillStartSelector:startSelector];//开始的代理
[UIView setAnimationDidStopSelector:stopSelector];//结束的代理
[UIView setAnimationDuration:seconds];
//改变后的参数,动画将会从初始化的参数向改变后的参数过渡
//改变后的参数,动画将会从初始化的参数向改变后的参数过渡
tempView.center =
tempView.center =
//大小transform
//大小transform
tempView.transform = CGAffineTransformMakeSca&wbr&le(number, number);
tempView.transform =
CGAffineTransformMakeScale(number,number);
tempView.alpha = 0;
tempView.alpha = 0;
CGAffineTransform newTransform = CGAffineTransformMakeRot&wbr&ation(M_PI);
[viewToAddAnimation setTransform:newTransform];
CGAffineTransform newTransform=
CGAffineTransformMakeRotation(M_PI);
[viewToAddAnimationsetTransform:newTransform];
//翻转两个View的动画:
把一个removeFromSupview同时把另一个addSubView,设置一下动画的翻转效果:上下左右选一个;
//翻转两个View的动画:
把一个removeFromSupview同时把另一个addSubView,设置一下动画的翻转效果:上下左右选一个;
[view1 removeFromSupview];
[view addSubView:view2];
[view1 removeFromSupview];
[view addSubView:view2];
//横向滑动效果等
//横向滑动效果等
[UIView commitAnimations];
[UIView commitAnimations];
三.CAAnimation实例:
弹出时抖动显示,模仿AlertView的弹出效果,可以将抖动结合用到其他的地方:
+(void) showCustemAlertViewInRec&wbr&t:(CGRect) frame inView:(UIView *) superview
UIView *tempView = [UIGloble newWhiteViewWithFrame:frame backgroundColor:[UIColor blueColor]];
[superview addSubview:tempView];//CGRectMake(40, 60, DeviceWidth-80, DeviceHeight-200)
CAKeyframeAnimation *animation=
animation = [CAKeyframeAnimation animationWithKeyPath:@&transform&];
animation.duration = 0.8;
animation.delegate =
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeF
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values =
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEa&wbr&seInEaseOut];
[tempView.layer addAnimation:animation forKey:nil];
[tempView release];
&#43;(void) showCustemAlertViewInRect:(CGRect)
frame inView:(UIView*)
UIView*tempView =[UIGloblenewWhiteViewWithFrame:frame
backgroundColor:[UIColor
blueColor]];
[superviewaddSubview:tempView];//CGRectMake(40, 60, DeviceWidth-80,DeviceHeight-200)
CAKeyframeAnimation *animation=nil;
animation =[CAKeyframeAnimationanimationWithKeyPath:@&transform&];
animation.duration =
animation.delegate =
animation.removedOnCompletion =YES;
animation.fillMode =
kCAFillModeForwards;
NSMutableArray *values= [NSMutableArray
[values addObject:[NSValue
valueWithCATransform3D:CATransform3DMakeScale(0.1,0.1,
[values addObject:[NSValue
valueWithCATransform3D:CATransform3DMakeScale(1.2,1.2,
[values addObject:[NSValue
valueWithCATransform3D:CATransform3DMakeScale(0.9,0.9,
[values addObject:[NSValue
valueWithCATransform3D:CATransform3DMakeScale(1.0,1.0,
animation.values =values;
animation.timingFunction =
[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[tempView.layer addAnimation:animation
forKey:nil];
[tempView release];
四.晃动动效果:CABasicAnimation动画举例:可以模仿iphone删除程序模式下的抖动效果:
CALayer*viewLayer=[self layer];
CABasicAnimation*animation=[CABasicAnimation animationWithKeyPath:@&transform&];
animation.duration=0.2;
animation.repeatCount = 100000;
animation.autoreverses=YES;
animation.fromValue=[NSValue valueWithCATransform3D:CATransform3DRotate(viewLayer.transform, -0.03, 0.0, 0.0, 0.03)];
animation.toValue=[NSValue valueWithCATransform3D:CATransform3DRotate(viewLayer.transform, 0.03, 0.0, 0.0, 0.03)];
[viewLayer addAnimation:animation forKey:@&wiggle&];
CALayer*viewLayer=[selflayer];
CABasicAnimation*animation=[CABasicAnimation
animationWithKeyPath:@&transform&];
animation.duration=0.2;
animation.repeatCount =
animation.autoreverses=YES;
animation.fromValue=[NSValuevalueWithCATransform3D:CATransform3DRotate(viewLayer.transform,
-0.03, 0.0,
0.0, 0.03)];
animation.toValue=[NSValue
valueWithCATransform3D:CATransform3DRotate(viewLayer.transform,
0.0, 0.03)];
[viewLayeraddAnimation:animation
forKey:@&wiggle&];
五.按照路径绘制动画的效果(CAKeyframeAnimation : CAPropertyAnimation)
指定几个点,会按照动画指定的轨迹出效果:可以自选几个比较明显重要的点来绘制出动画
1CAKeyframeAnimation
*animation = [CAKeyframeAnimation animationWithKeyPath:@&position&];
[animation setDuration:0.8];
CGPoint p1 = tempButton.
CGPoint p2 = CGPointMake(152, 97);
CGPoint p3 = CGPointMake(189, 110);
CGPoint p4 = CGPointMake(220, 124);
CGPoint p5 = CGPointMake(245, 163);
CGPoint p6 = CGPointMake(220, 250);
CGPoint p7 = CGPointMake(177, 379);
[animation setValues:[NSArray arrayWithObjects:
[NSValue valueWithCGPoint:p1],
[NSValue valueWithCGPoint:p2],
[NSValue valueWithCGPoint:p3],
[NSValue valueWithCGPoint:p4],
[NSValue valueWithCGPoint:p5],
[NSValue valueWithCGPoint:p6],
[NSValue valueWithCGPoint:p7],
[animation setKeyTimes:[NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.3],
[NSNumber numberWithFloat:0.4],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.6],
[NSNumber numberWithFloat:0.7],
[NSNumber numberWithFloat:0.8],
//[animation setAutoreverses:YES];//返回到原始状态
[tempButton.layer addAnimation:animation forKey:@&BookView-Fly&];
[UIGloble addAnimationFade:tempButton duraion:0.8];
[UIGloble addAnimationScal:tempButton toPoint:tempButton.center
lightState:YES delegate:tempButton startSelector:nil
stopSelector:@selector(removeFromSuperview) scaleNumber:0.1
duraion:0.8];
[tempButton release];
[self performSelector:@selector(changeBadgeValue) withObject:nil
afterDelay:0.8];
六.CATransition,cube动画翻转,privateAPI
CATransition *animation = [CATransition animation];
animation.delegate =
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEase&wbr&InO
animation.fillMode = kCAFillModeR
animation.removedOnCompletion = NO;
animation.type = @&cube&;
[[UIApplication sharedApplication].keyWindow.layer
addAnimation:animation forKey:@&animationID&];
CAKeyframeAnimation *animation=
[CAKeyframeAnimation animationWithKeyPath:@&position&];
[animationsetDuration:0.8];
CGPointp1 = tempButton.center;
CGPoint p2= CGPointMake(152,
CGPointp3 = CGPointMake(189,
CGPoint p4= CGPointMake(220,
CGPointp5 = CGPointMake(245,
CGPoint p6= CGPointMake(220,
CGPointp7 = CGPointMake(177,
[animationsetValues:[NSArrayarrayWithObjects:
[NSValue valueWithCGPoint:p1],
[NSValuevalueWithCGPoint:p2],
[NSValue valueWithCGPoint:p3],
[NSValuevalueWithCGPoint:p4],
[NSValue valueWithCGPoint:p5],
[NSValuevalueWithCGPoint:p6],
[NSValue valueWithCGPoint:p7],
[animation setKeyTimes:[NSArray
arrayWithObjects:
[NSNumbernumberWithFloat:0.0],
[NSNumber numberWithFloat:0.3],
[NSNumbernumberWithFloat:0.4],
[NSNumber numberWithFloat:0.5],
[NSNumbernumberWithFloat:0.6],
[NSNumber numberWithFloat:0.7],
[NSNumbernumberWithFloat:0.8],
//[animationsetAutoreverses:YES];//返回到原始状态
[tempButton.layer
addAnimation:animation forKey:@&BookView-Fly&];
[UIGlobleaddAnimationFade:tempButton
duraion:0.8];
[UIGloble addAnimationScal:tempButton
toPoint:tempButton.center
lightState:YES delegate:tempButton
startSelector:nil stopSelector:@selector(removeFromSuperview)scaleNumber:0.1
duraion:0.8];
[tempButtonrelease];
[self performSelector:@selector(changeBadgeValue)
withObject:nil afterDelay:0.8];
六.CATransition,cube动画翻转,privateAPI
CATransition*animation =[CATransitionanimation];
animation.delegate =
animation.duration =
animation.timingFunction =
UIViewAnimationCurveEaseInOut;
animation.fillMode =
kCAFillModeRemoved;
animation.removedOnCompletion=
animation.type = @&cube&;
[[UIApplication sharedApplication].keyWindow.layer
addAnimation:animation forKey:@&animationID&];
总结出来的:
实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制,
第一种是UIView,UIView方式可能在低层也是使用CATransition进行了封装,它只能用于一些简单的、常用的效果展现,这里写一个常用的示例代码,供大家参考。
[UIView beginAnimations:@&Curl&context:nil];//动画开始
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitio&wbr&nCurlUp forView:myview cache:YES];
[myview removeFromSuperview];
[UIView commitAnimations];
[UIView beginAnimations:@&Curl&context:nil];//动画开始
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUpforView:myview
cache:YES];
[myview removeFromSuperview];
[UIView commitAnimations];
第二种方式相对复杂一些,但如果更好的进行控制,还是使用这种方法吧,基本使用方法可以看一下如下例子:
CATransition *animation = [CATransition animation];
[animation setDuration:1.25f];
[animation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEa&wbr&seIn]];
[animation setType:kCATransitionReveal];
[animation setSubtype: kCATransitionFromBottom];
[self.view.layer addAnimation:animation forKey:@&Reveal&];
CATransition*animation =[CATransitionanimation];
[animationsetDuration:1.25f];
[animation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseIn]];
[animation setType:kCATransitionReveal];
[animationsetSubtype:kCATransitionFromBottom];
[self.view.layer
addAnimation:animation forKey:@&Reveal&];
还有一种设置动画类型的方法,不用setSubtype,只用setType
[animation setType:@&suckEffect&];
这里的suckEffect就是效果名称,可以用的效果主要有:
pageCurl 向上翻一页
pageUnCurl 向下翻一页
rippleEffect 滴水效果
suckEffect 收缩效果,如一块布被抽走
cube 立方体效果
oglFlip 上下翻转效果
最后再给出一种常用代码供大家参考。
// Curl the image up or down
CATransition *animation = [CATransition animation];
[animation setDuration:0.35];
[animation setTimingFunction:UIViewAnimationCurveEase&wbr&InOut];
if (!curled){
//animation.type = @&mapCurl&;
animation.type = @&pageCurl&;
animation.fillMode = kCAFillModeF
animation.endProgress = 0.99;
//animation.type = @&mapUnCurl&;
animation.type = @&pageUnCurl&;
animation.fillMode = kCAFillModeB
// Curl theimage up or down
CATransition *animation = [CATransition
animation];
[animation setDuration:0.35];
[animationsetTimingFunction:UIViewAnimationCurveEaseInOut];
if(!curled){
//animation.type = @&mapCurl&;
animation.type = @&pageCurl&;
animation.fillMode =
kCAFillModeForwards;
animation.endProgress =
//animation.type = @&mapUnCurl&;
animation.type =@&pageUnCurl&;
animation.fillMode =
kCAFillModeBackwards;
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:47145次
排名:千里之外
原创:32篇
转载:79篇
(2)(1)(1)(1)(1)(2)(1)(1)(1)(2)(5)(1)(2)(2)(6)(2)(6)(3)(6)(1)(1)(13)(25)(3)(2)(10)(1)(7)(2)

我要回帖

更多关于 uialertview动画 的文章

 

随机推荐