优化PhoneGAP的Splashscreen

本文介绍如何在PhoneGap 2.0.0中修改CDVSplashScreen类来实现更自然的启动屏过渡动画效果。通过iOS动画库的应用,能够增强用户体验,并提供了具体的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基于PhoneGap 2.0.0 源码版本,修改了 Commands 包下的 CDVSplashScreen 类,使用 Splashscreen的过度效果更自然,以下代码只是抛砖引玉,可以利用ios的动画库实现更多的过度动画,如:为Splashscreen增加一个按钮等。

- (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).imageView.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).imageView.hidden = !show; ((CDVViewController*)viewController).activityView.hidden = !show; }

 

转载于:https://www.cnblogs.com/uppower/archive/2012/09/05/ios-phonegap-splashscreen-animation.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值