iOS自帶動畫效果的實(shí)例代碼
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自帶動畫效果的實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- iOS中給自定義tabBar的按鈕添加點(diǎn)擊放大縮小的動畫效果
- iOS點(diǎn)擊查看大圖的動畫效果
- iOS仿支付寶芝麻信用分?jǐn)?shù)儀表盤動畫效果
- iOS 屏幕解鎖文字動畫效果
- iOS實(shí)現(xiàn)知乎和途家導(dǎo)航欄漸變的文字動畫效果
- IOS實(shí)現(xiàn)視頻動畫效果的啟動圖
- Android UI設(shè)計系列之自定義SwitchButton開關(guān)實(shí)現(xiàn)類似IOS中UISwitch的動畫效果(2)
- 基于JS實(shí)現(xiàn)Android,iOS一個手勢動畫效果
- IOS框架Spring常用的動畫效果
- IOS等待時動畫效果的實(shí)現(xiàn)
- iOS使用UICountingLabel實(shí)現(xiàn)數(shù)字變化的動畫效果
相關(guān)文章
UITableView 實(shí)現(xiàn)汽車品牌(demo)
UITableView堪稱UIKit里面最復(fù)雜的一個控件了,使用起來不算難,但是要用好并不容易,當(dāng)使用的時候我們必須要考慮到后臺數(shù)據(jù)的設(shè)計,tableViewCell的設(shè)計和重用以及tableView的效率等問題,下面小編通過UITableView 實(shí)現(xiàn)汽車品牌,需要的朋友可以參考下2015-08-08
iOS內(nèi)存管理中引用計數(shù)的學(xué)習(xí)
文章給大家分享了關(guān)于iOS內(nèi)存管理中引用計數(shù)的相關(guān)知識點(diǎn),對此有需要的朋友可以跟著學(xué)習(xí)下。2018-05-05
iOS自定義UIBarButtonItem的target和action示例代碼
這篇文章主要給大家介紹了關(guān)于iOS自定義UIBarButtonItem的target和action的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-02-02
iOS開發(fā)之tableView實(shí)現(xiàn)左滑刪除功能
我們在使用一些應(yīng)用的時候,在滑動一些聯(lián)系人的某一行的時候,會出現(xiàn)刪除、置頂、更多等等的按鈕,下面這篇文章主要就介紹了iOS用tableView實(shí)現(xiàn)左劃刪除功能的方法,有需要的朋友們可以參考借鑒,下面來一起看看吧。2017-01-01
IOS實(shí)現(xiàn)百度地圖自定義大頭針和氣泡樣式
這篇文章主要介紹了 IOS百度地圖自定義大頭針和氣泡的實(shí)例代碼,非常不錯,具有參考借鑒價值,需要的朋友參考下2016-12-12
iOS開發(fā)之時間戳(或date)轉(zhuǎn)字符串的實(shí)例代碼
這篇文章主要介紹了iOS開發(fā)之時間戳(或date)轉(zhuǎn)字符串的實(shí)例代碼,需要的朋友可以參考下2017-10-10
iOS App開發(fā)中UIViewController類的使用教程
UIViewController是iOS中控制視圖的關(guān)鍵所在,這里我們將針對UIViewController的聲明周期與主要屬性和方法,來總結(jié)iOS App開發(fā)中UIViewController類的使用教程2016-07-07

