UIView animation


UIView的動畫其實很不復雜,但是流程老忘記,幾個筆記

看過官方文檔的都知道,官方推薦在iOS4以后使用[UIView animateWithDuration:animations:],而不是原來的[UIView beginAnimations:context:],來完成動畫,雖然二者功能幾乎完全相同,但使用前者在一些情況下會方便不少,這些內容可以參考官方文檔View Programming Guide For iOS的Animation一節.

二者有一個值得新手注意的區別就是[UIView animateWithDuration:animations:]默認會禁止觸摸,手勢等的響應,這可以通過設置option選項來解決(直接引用StackOverFlow的一段了):

UIViewAnimationOptions options = UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction;

 

[UIView animateWithDuration:0.2 delay:0.0 options:options animations:^

 {

     highlightView.alpha = 1.0;

 

 } completion:nil];


、、

[UIView animateWithDuration:duration

                          delay:0.0

                        options:UIViewAnimationCurveEaseInOut //設置動畫類型

                     animations:^{

                         //開始動畫

                         [self updateArrowBtnTitle:YES];

                         rotateView.transform = CGAffineTransformMakeRotation((stickToDegrees/180)*M_PI);

                     }

                     completion:^(BOOL finished){

                         // 動畫結束時的處理

                     }];

[UIView animateWithDuration:] 方法僅支持ios4.0及以上版本。如果要兼容以前的版本的話,還是需要使用 [UIView beginAnimation:] 方法

[UIView beginAnimations:nil context:nil];

    // fade out

    helpImageBtn.alpha = 0.0f;

    // set animation did stop selector

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

    [UIView commitAnimations];


   - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

    if (self.retainedHelpImageBtn.superview) //先判斷父視圖再執行視圖移除

        [self.retainedHelpImageBtn removeFromSuperview];

   }

FROM:http://blog.csdn.net/zhanglei5415/article/details/7006626 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM