iOS自帶動畫效果的實例代碼
更新時間:2016年12月27日 10:21:56 作者:紹棠
本文給大家分享ios自帶動畫效果的實現(xiàn)代碼,非常不錯,具有參考借鑒價值,需要的朋友參考下吧
1.普通動畫:
[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2]; frame.origin.x += 150; [img setFrame:frame]; [UIView commitAnimations];
2.連續(xù)動畫(一系列圖像):
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.fillMode = 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]; } ]; } ];
以上所述是小編給大家介紹的iOS自帶動畫效果的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
您可能感興趣的文章:
- iOS中給自定義tabBar的按鈕添加點擊放大縮小的動畫效果
- iOS點擊查看大圖的動畫效果
- iOS仿支付寶芝麻信用分數(shù)儀表盤動畫效果
- iOS 屏幕解鎖文字動畫效果
- iOS實現(xiàn)知乎和途家導航欄漸變的文字動畫效果
- IOS實現(xiàn)視頻動畫效果的啟動圖
- Android UI設計系列之自定義SwitchButton開關實現(xiàn)類似IOS中UISwitch的動畫效果(2)
- 基于JS實現(xiàn)Android,iOS一個手勢動畫效果
- IOS框架Spring常用的動畫效果
- IOS等待時動畫效果的實現(xiàn)
- iOS使用UICountingLabel實現(xiàn)數(shù)字變化的動畫效果
相關文章
UITableView 實現(xiàn)汽車品牌(demo)
UITableView堪稱UIKit里面最復雜的一個控件了,使用起來不算難,但是要用好并不容易,當使用的時候我們必須要考慮到后臺數(shù)據(jù)的設計,tableViewCell的設計和重用以及tableView的效率等問題,下面小編通過UITableView 實現(xiàn)汽車品牌,需要的朋友可以參考下2015-08-08iOS自定義UIBarButtonItem的target和action示例代碼
這篇文章主要給大家介紹了關于iOS自定義UIBarButtonItem的target和action的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-02-02iOS開發(fā)之tableView實現(xiàn)左滑刪除功能
我們在使用一些應用的時候,在滑動一些聯(lián)系人的某一行的時候,會出現(xiàn)刪除、置頂、更多等等的按鈕,下面這篇文章主要就介紹了iOS用tableView實現(xiàn)左劃刪除功能的方法,有需要的朋友們可以參考借鑒,下面來一起看看吧。2017-01-01iOS App開發(fā)中UIViewController類的使用教程
UIViewController是iOS中控制視圖的關鍵所在,這里我們將針對UIViewController的聲明周期與主要屬性和方法,來總結iOS App開發(fā)中UIViewController類的使用教程2016-07-07