温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

优化PhoneGAP的Splashscreen 类

发布时间:2020-06-11 05:50:06 来源:网络 阅读:495 作者:kennyluo 栏目:开发技术

  基于PhoneGap 2.0.0 源码,修改 Commands 包下的 CDVSplashScreen 类,使用 Splashscreen的过度效果更自然[渐变透明|左右上下Slide|翻页],以下代码只是抛砖引玉,可以利用ios的动画库实现更多的过度动画。 希望本文能帮助一些孩童学习PHONEGAP的用法,更灵活运用源码满足自己的开发需求。

 

  1. - (void) __show:(BOOL)show 
  2.     // Legacy support - once deprecated classes removed, clean this up 
  3.     id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate]; 
  4.      
  5.     if ([delegate respondsToSelector:@selector(viewController)]) { 
  6.         id vc = [delegate performSelector:@selector(viewController)]; 
  7.         if ([vc isKindOfClass:[CDVViewController class]]) { 
  8.             [UIView beginAnimations:nil context:nil]; 
  9.             [UIView setAnimationDuration:0.9]; 
  10.             [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:((CDVViewController*)vc).view cache:YES]; 
  11.             [UIView setAnimationDelegate:((CDVViewController*)vc)]; 
  12.        // 动画结束后执行隐藏操作 
  13.             [UIView setAnimationDidStopSelector:@selector(showAnimationDone:vc:show:finished:context:)]; 
  14.             ((CDVViewController*)vc).p_w_picpathView.alpha = 0.0;//让Splashscreen 的填充图片的透明度渐渐变为0; 
  15.             ((CDVViewController*)vc).activityView.alpha = 0.0; //让Splashscreen 的活动视图的透明度渐渐变为0; 
  16.             [UIView commitAnimations]; 
  17.         } 
  18.     } 
  19.  
  20. //动画结束后隐藏Splashscreen 
  21. - (void) showAnimationDone:(id*)viewController showOrhide:(BOOL)show animationID:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
  22.     ((CDVViewController*)viewController).p_w_picpathView.hidden = !show; 
  23.     ((CDVViewController*)viewController).activityView.hidden = !show; 
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI