基于PhoneGap 2.0.0 源碼,修改 Commands 包下的 CDVSplashScreen 類,使用 Splashscreen的過度效果更自然[漸變透明|左右上下Slide|翻頁],以下代碼只是拋磚引玉,可以利用ios的動畫庫實現更多的過度動畫。 希望本文能幫助一些孩童學習PHONEGAP的用法,更靈活運用源碼滿足自己的開發需求。
- - (void) __show:(BOOL)show
- {
- // Legacy support - once deprecated classes removed, clean this up
- id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
- if ([delegate respondsToSelector:@selector(viewController)]) {
- id vc = [delegate performSelector:@selector(viewController)];
- if ([vc isKindOfClass:[CDVViewController class]]) {
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:0.9];
- [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:((CDVViewController*)vc).view cache:YES];
- [UIView setAnimationDelegate:((CDVViewController*)vc)];
- // 動畫結束后執行隱藏操作
- [UIView setAnimationDidStopSelector:@selector(showAnimationDone:vc:show:finished:context:)];
- ((CDVViewController*)vc).p_w_picpathView.alpha = 0.0;//讓Splashscreen 的填充圖片的透明度漸漸變為0;
- ((CDVViewController*)vc).activityView.alpha = 0.0; //讓Splashscreen 的活動視圖的透明度漸漸變為0;
- [UIView commitAnimations];
- }
- }
- }
- //動畫結束后隱藏Splashscreen
- - (void) showAnimationDone:(id*)viewController showOrhide:(BOOL)show animationID:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
- {
- ((CDVViewController*)viewController).p_w_picpathView.hidden = !show;
- ((CDVViewController*)viewController).activityView.hidden = !show;
- }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。