国产精品电影_久久视频免费_欧美日韩国产激情_成年人视频免费在线播放_日本久久亚洲电影_久久都是精品_66av99_九色精品美女在线_蜜臀a∨国产成人精品_冲田杏梨av在线_欧美精品在线一区二区三区_麻豆mv在线看

Xcode學習之視圖轉換例子實踐

移動開發 iOS
本文介紹的是Xcode學習之視圖轉換例子實踐,講述了xcode中視圖轉換例子實踐的內容,先來看詳細內容。

Xcode學習之視圖轉換例子實踐是本文要介紹的內容,主要介紹了xcode視圖轉換例子實踐的教程。讓我們進一步的去學習xcode的相關內容,先來看本文詳細介紹。

翻轉(類似翻書)視圖效果,兩種實現方式

滑動視圖效果

分別看各自實現的重點:

翻轉視圖效果例子

在官方上,提供

  1. UIViewAnimationTransitionFlipFromLeft和UIViewAnimationTransitionFlipFromRight 

方法,來實現視圖向左或向右翻轉。

在UIView動畫塊中使用轉換,需要2個工作:

1、必須將轉換作為塊參數添加

2、應該在塊內部重新安排視圖順序。

效果代碼如下:

  1. - (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{      
  2. // Start Animation Block     
  3.  CGContextRef context = UIGraphicsGetCurrentContext();      
  4.  [UIView beginAnimations:nil context:context];      
  5.  [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];  
  6.  //*    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];      
  7.  [UIView setAnimationDuration:1.0];         
  8.  // Animations    [[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];  
  9.  //*         
  10.  // Commit Animation Block      
  11.  [UIView commitAnimations];  
  12.  } 

注意,此代碼寫在touchesEnded事件上的,也是符合翻轉邏輯

上述代碼中帶有//*的地方,就是所需2個工作。

***處表示向左翻轉,翻轉的對象是當前視圖的上級視圖,并緩存

第二處表示子視圖集合中,0和1之間交換

UIView類

類方法:(動畫部分)

  1. setAnimationTransition:forView:cache:  
  2. + (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache  
  3.  
  4. Sets a transition to apply to a view during an animation block. 

方法:

  1. exchangeSubviewAtIndex:withSubviewAtIndex:  
  2.     - (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2  
  3.  
  4.     Exchanges the subviews at the specified indices.  
  5.     index1: The index of the first subview in the receiver.  
  6.     index2: The index of the second subview in the receiver. 

關于方法exchangeSubviewAtIndex:withSubviewAtIndex:實現的效果也可以用其他方式來實現。比如:

  1. UIViewController Controller  
  2.     UIView v1  
  3.     UIView v2  
  4. Controller.view = v1;//v1 front  
  5. Controller.view = v2;//v2 front 

當然,這只是實踐中應用,但不一定這么用。用UIViewController實現不了動畫效果,至少現在我不知道UIViewController本身可否實現動畫效果。

關于另外一種方式來實現動畫效果Core Animation Transition,作用于層,而非視圖,看如下代碼:

  1. - (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{      
  2. CATransition *animation = [CATransition animation];      
  3. [animation setDelegate:self];      
  4. [animation setDuration:1.0f];      
  5. [animation setTimingFunction:UIViewAnimationCurveEaseInOut];     
  6. [animation setType: kCATransitionPush];      
  7. [animation setSubtype: kCATransitionFromLeft];         
  8. [[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];      
  9. [[[self superview] layer] addAnimation:animation forKey:@"transitionViewAnimation"];    
  10.  } 

#p#

CATransition類此類針對層執行轉換動畫繼承CAAnimation : NSObject屬性:

  1. delegate:  
  2. @property(retain) id delegate  
  3.  
  4.     Specifies the receiver’s delegate object.  
  5.  
  6. duration:  
  7. @property CFTimeInterval duration  
  8.  
  9.     Specifies the basic duration of the animation, in seconds. (required)  
  10.  
  11. timingFunction:  
  12. @property(retain) CAMediaTimingFunction *timingFunction  
  13.  
  14.     An optional timing function defining the pacing of the animation.  
  15.  
  16. subtype  
  17. @property(copy) NSString *subtype  
  18.     Specifies an optional subtype that indicates the direction for the predefined motion-based transitions.  
  19.  
  20. Discussion  
  21.     The possible values are shown in “Common Transition Subtypes”. The default is nil.  
  22.  
  23. type  
  24. @property(copy) NSString *type  
  25. Discussion  
  26.     The possible values are shown in “Common Transition Types”. The default is kCATransitionFade. 

Constants/常量

  1. Common Transition Types  
  2.     These constants specify the transition types that can be used with the type property.  
  3.     NSString * const kCATransitionFade;  
  4.     NSString * const kCATransitionMoveIn;  
  5.     NSString * const kCATransitionPush;  
  6.     NSString * const kCATransitionReveal;  
  7.     kCATransitionFade  
  8.         The layer’s content fades as it becomes visible or hidden.  
  9.     kCATransitionMoveIn  
  10.         The layer’s content slides into place over any existing content. The “Common Transition Subtypes” are used with this transition.  
  11.     kCATransitionPush  
  12.         The layer’s content pushes any existing content as it slides into place. The “Common Transition Subtypes” are used with this transition.  
  13.     kCATransitionReveal  
  14.         The layer’s content is revealed gradually in the direction specified by the transition subtype. 
  15. The “Common Transition Subtypes” are used with this transition.  
  16. Common Transition Subtypes  
  17.     These constants specify the direction of motion-based transitions. They are used with the subtype property.  
  18.     NSString * const kCATransitionFromRight;  
  19.     NSString * const kCATransitionFromLeft;  
  20.     NSString * const kCATransitionFromTop;  
  21.     NSString * const kCATransitionFromBottom;  
  22.     kCATransitionFromRight  
  23.         The transition begins at the right side of the layer.  
  24.     kCATransitionFromLeft  
  25.         The transition begins at the left side of the layer.  
  26.     kCATransitionFromTop  
  27.         The transition begins at the top of the layer.  
  28.     kCATransitionFromBottom  
  29.         The transition begins at the bottom of the layer.  
  30.     Declared in CAAnimation.h. 

在后續例子中也有此CATransition類的學習,具體方法實際中去參考CALayer類。

方法:

  1. addAnimation:forKey:  
  2.     - (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key  
  3.     Add an animation object to the receiver’s render tree for the specified key.  
  4.     anim: The animation to be added to the render tree.  
  5.     key: A string that specifies an identifier for the animation. 

在后續的滑動視圖中,使用CATransition實現,關鍵在于生成一個控制層運動的對象,看代碼:

  1. - (CATransition *) getAnimation:(NSString *) direction{     
  2.  CATransition *animation = [CATransition animation];      
  3.  [animation setDelegate:self];     
  4.   [animation setType:kCATransitionPush];     
  5.    [animation setSubtype:direction];      
  6.    [animation setDuration:1.0f];      
  7.    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];  
  8. return animation;  

  1. [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

這句代碼和前面有些不一樣吧。

另外一個關鍵:定義一個滑動方向,在touchesBegan初始化,在touchesMoved獲取當前值,在touchesEnded中使用。多閱讀此代碼

小結:Xcode學習之視圖轉換例子實踐的內容介紹完了,希望本文對你有所幫助!

責任編輯:zhaolei 來源: 博客園
相關推薦

2011-08-01 10:01:12

Xcode UIView 動畫

2011-07-20 14:31:56

XCode User Scrip 腳本

2011-08-01 15:57:58

2011-08-01 16:50:28

Xcode 動態 View

2011-08-01 17:01:02

Xcode WindowBase View

2011-08-01 17:50:28

Xcode

2011-08-11 16:31:08

XCode

2011-08-10 14:00:22

XcodeUIWebView視頻

2011-08-18 10:17:21

Xcode4Xcode

2015-05-25 10:01:17

WatchKitAPP

2011-07-25 15:42:38

Xcode Vim

2010-04-19 10:20:19

Oracle參數

2013-07-25 15:19:23

iOS開發學習Xcode打包framiOS開發

2011-08-08 17:05:02

XCode UserScript 腳本

2011-08-01 17:31:25

Xcode開發 Cocoa

2011-08-01 09:26:51

Xcode Xcode 4 Instrument

2011-08-19 15:16:41

XCodeUserScripts腳本

2014-03-12 09:52:17

XcodeCode Snippe

2011-07-29 18:52:59

Xcode安裝 MacOS Windows

2011-07-19 15:55:09

Xcode Interface Builder
點贊
收藏

51CTO技術棧公眾號

97久久人人超碰caoprom欧美 | v天堂福利视频在线观看| 一区二区不卡在线视频 午夜欧美不卡' | 福利微拍一区二区| 国产精品vip| 亚洲色图美女| 黄视频网站在线观看| 国产激情视频在线观看| 有色激情视频免费在线| 日韩免费一区二区三区| 国产精品扒开腿爽爽爽视频| 欧美激情精品久久久久| 亚洲国产精品久久久久久| 欧美影视一区二区三区| 国产精品电影一区二区三区| 天堂资源在线中文精品| 亚洲免费大片| 久久男女视频| 媚黑女一区二区| 麻豆精品在线播放| 奇米色777欧美一区二区| 亚洲欧美卡通另类91av| 香蕉av777xxx色综合一区| 中文在线一区| 老司机一区二区三区| 欧美黄色aaaa| 国产日韩欧美在线播放不卡| 亚洲第一伊人| 视频一区二区欧美| 激情深爱一区二区| 狠狠色2019综合网| 夫妻av一区二区| 99视频精品免费视频| 国产欧美日韩三级| 国产精品理伦片| 亚洲欧洲制服丝袜| 777精品伊人久久久久大香线蕉| 制服丝袜中文字幕亚洲| 精品国产一区二区三区不卡| 精品福利视频一区二区三区| 欧美成年人视频网站| 国产精品爽爽爽| 97碰碰视频| 99中文字幕在线观看| 女性女同性aⅴ免费观女性恋| 中文字幕国内自拍| 在线视频色在线| 黄色网页在线免费看| av成人影院在线| 好吊妞国产欧美日韩免费观看网站| 日韩中文在线电影| 宅男噜噜噜66一区二区| 高清久久久久久| 一本色道a无线码一区v| 亚洲成**性毛茸茸| 欧美激情一区二区三级高清视频| 99免费在线视频观看| 国产精品成人久久电影| 超碰在线免费| 一个人看的www视频在线免费观看 一个人www视频在线免费观看 | 一区二区成人在线| 日韩精品专区在线| 欧美华人在线视频| 麻豆av一区二区三区| 天天操,天天操| 黄网站在线观| 久久久免费毛片| 国产成人澳门| 免费xxxx性欧美18vr| 国产精品盗摄一区二区三区| 91精品国产乱码| 欧洲s码亚洲m码精品一区| 日韩和欧美的一区二区| 色免费在线视频| 在线三级电影| 欧美a级成人淫片免费看| 久久久久国产精品人| 亚洲一二三在线| 亚洲国产精品一区二区久久恐怖片| 美女一区二区在线观看| 日本福利片高清在线观看| www.久久.com| 激情综合色丁香一区二区| 欧美日免费三级在线| 99国产精品久久久久老师| 大胆高清日本a视频| 亚洲一区 二区| 久久综合五月天婷婷伊人| 国产亚洲精品美女久久久| 亚洲在线播放电影| 成人av影院在线观看| 国产精品美女久久久| 欧美一区二区在线免费播放 | 人妻夜夜添夜夜无码av| 中文字幕在线播放第一页| 色呦呦在线免费观看| 精品一区二区三区免费看| 日韩在线黄色| 久久蜜桃av一区精品变态类天堂| 日韩一区二区三区三四区视频在线观看| 欧美一区二区在线看| 亚洲国产又黄又爽女人高潮的| 麻豆乱码国产一区二区三区 | 亚洲国产美女搞黄色| 亚洲欧洲在线免费| 国产成人亚洲综合91| 丝袜制服一区二区三区| jizz亚洲女人高潮大叫| 国产精品久久久久久久第一福利 | 日韩av一区二区三区美女毛片| www..com日韩| 中日韩脚交footjobhd| 久久午夜av| 制服丝袜中文字幕亚洲| 国产高清一区视频| 中文字幕中文字幕在线中高清免费版| 久久国产精品一区二区| 欧美日韩精品久久久| 国产精品第8页| 青青草免费在线| 精品99视频| 欧美精品1区2区| 视频一区免费观看| а√天堂中文在线资源8| 午夜影院在线播放| 国产乱人伦偷精品视频不卡| 91.com视频| 亚洲第一精品区| 麻豆久久久久| 国产精品久久99| 国产精品十八以下禁看| 国产第一页在线| 日本成人在线视频网站| 精品日韩欧美一区二区| 一区一区视频| 欧美成人福利| 亚洲天堂免费看| 成人欧美一区二区三区视频 | 国产亚洲视频系列| 2019亚洲男人天堂| 素人av在线| 激情图区综合网| 久久乐国产精品| 欧美日韩经典丝袜| 国产精品久久久久9999高清| 在线成人高清不卡| 一本色道久久综合亚洲精品婷婷| 一二区成人影院电影网| 香蕉成人伊视频在线观看| 任我爽在线视频精品一| 日本一区二区三区中文字幕 | 久久久久久97三级| 久青草视频在线播放| 希岛爱理av免费一区二区| 67194成人在线观看| 精品久久久久久久无码| 亚洲精品1区| 国产精品极品尤物在线观看 | 亚洲黄页在线观看| 欧美精品黑人性xxxx| 久久亚洲精品无码va白人极品| 伊甸园亚洲一区| 亚洲成色777777在线观看影院 | 日韩一级免费看| 在线亚洲自拍| 成人在线精品视频| 久久亚洲精品中文字幕| 在线亚洲免费视频| 国产三级香港三韩国三级| 日韩中文字幕1| 国产欧美日韩精品在线观看| 国内自拍欧美| 欧美视频裸体精品| 成人精品一区二区三区电影免费| 久久亚洲人体| 欧美精品欧美精品系列| 免费高清视频日韩| 91丨porny丨户外露出| 精品国产一区二区三区麻豆小说| 免费成人结看片| 日韩av手机在线| 第一福利在线视频| 欧洲亚洲国产日韩| 草裙成人精品一区二区三区 | 欧美日韩成人一区二区| 亚洲免费av一区二区三区| 麻豆91精品视频| 欧美成人综合一区| 欧美激情偷拍| 国产精品com| 91精品国偷自产在线电影| 欧美日韩一区二区在线观看视频| 亚洲国产精品www| 亚洲美女色禁图| 成人综合色站| 99久久九九| 成人av资源网| 国产亚洲高清视频| 国产成人三级视频| 国产厕拍一区|