• 窗口抖动效果


    方法1
    
    -(void)earthquake:(UIView*)itemView
    {
        CGFloat t =2.0;
    
        CGAffineTransform leftQuake  =CGAffineTransformTranslate(CGAffineTransformIdentity, t,-t);
        CGAffineTransform rightQuake =CGAffineTransformTranslate(CGAffineTransformIdentity,-t, t);
    
        itemView.transform = leftQuake;  // starting point
    
        [UIView beginAnimations:@"earthquake" context:itemView];
        [UIView setAnimationRepeatAutoreverses:YES];// important
        [UIView setAnimationRepeatCount:5];
        [UIView setAnimationDuration:0.07];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(earthquakeEnded:finished:context:)];
    
        itemView.transform = rightQuake;// end here & auto-reverse
    
        [UIView commitAnimations];
    }
    
    -(void)earthquakeEnded:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context 
    {
        if([finished boolValue]) 
        {
            UIView* item =(UIView*)context;
            item.transform =CGAffineTransformIdentity;
        }
    
    }
    
    
    
    
    方法2
    
    -(void)shakeView:(UIView*)viewToShake
    {
        CGFloat t =2.0;
        CGAffineTransform translateRight  =CGAffineTransformTranslate(CGAffineTransformIdentity, t,0.0);
        CGAffineTransform translateLeft =CGAffineTransformTranslate(CGAffineTransformIdentity,-t,0.0);
    
        viewToShake.transform = translateLeft;
    
        [UIView animateWithDuration:0.07 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{
            [UIView setAnimationRepeatCount:2.0];
            viewToShake.transform = translateRight;
        } completion:^(BOOL finished){
            if(finished){
                [UIView animateWithDuration:0.05 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
                    viewToShake.transform =CGAffineTransformIdentity;
                } completion:NULL];
            }
        }];
    
    }
  • 相关阅读:
    图的存储结构(精编)
    二叉树的输入
    哈夫曼树及编码
    C. Bits (Codeforces Round #276 (Div. 2) )
    C++ Map 容器
    POJ 1080 Human Gene Functions(dp)
    数和二叉树——二叉树的建立及应用(遍历等)(基础篇)
    数独问题的介绍及POJ 2676-Sudoku(dfs+剪枝)
    【数据结构】——稀疏矩阵转置
    POJ 3083 Children of the Candy Corn
  • 原文地址:https://www.cnblogs.com/gaoxiao228/p/2482247.html
Copyright © 2020-2023  润新知