您的位置:首页 > 移动开发 > IOS开发

iOS 设置启动页动画

2017-04-03 13:38 183 查看
商业项目不方便截取效果图 也懒得写demo了 随便缕下

思路是使用LaunchScreen.storyboard (捯饬了一晚上LaunchImage  也不知道怎么网LaunchImage上加动画)

1.General - App Icons and Launch Images - Launch Screen File 宣泄 LaunchScreen.storyboard

2.到LaunchScreen.storyboard 下 勾选  Is Initial View Controller

3.然后 storyboard里画你的界面

4.可能一运行是白屏 或 黑屏 不显示图片, 将图片放到跟目录下 就好了

我需要在界面上漂浮很多东西,除了背景 logo 几张固定图片不移动 其他都移动


2. 





- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {

    

    //启动页延时1.5

    [NSThread
sleepForTimeInterval:1.5f];

    

    MyMainViewController *vc = [[MyMainViewController
alloc]init];

    UINavigationController *nav = [[UINavigationController
alloc]initWithRootViewController:vc];

    nav.delegate =
self;

    self.window.rootViewController
= nav ;

    [self.window
makeKeyAndVisible];

    

   [self
launchAnimation];

    return
YES;

}

#pragma mark - 启动页动画

- (void)launchAnimation {

   UIViewController *viewController = [[UIStoryboard
storyboardWithName:@"LaunchScreen"
bundle:nil]
instantiateViewControllerWithIdentifier:@"LaunchScreen"];

    UIView *launchView = viewController.view;

    UIWindow *mainWindow = [UIApplication
sharedApplication].keyWindow;

    launchView.frame = [UIApplication
sharedApplication].keyWindow.frame;

    [mainWindow addSubview:launchView];

    

    NSMutableArray *imageA = [NSMutableArray
arrayWithCapacity:1];

    for (UIImageView *imageV
in launchView.subviews) {

        if (imageV.tag !=
1001 && imageV.tag !=
1002 && imageV.tag !=
1003&& imageV.tag !=
1004 && imageV.tag !=
1005) {

             [imageA addObject:imageV];

        }

    }

    

    [UIView
animateWithDuration:2
delay:0.0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{

        int i =
0;

        while (i < imageA.count) {

               ((UIImageView *)imageA[i]).transform =
CGAffineTransformMakeTranslation(5,
5);

            i++;

        }

    } completion:^(BOOL finished) {

        [UIView
animateWithDuration:5
animations:^{

            int i =
0;

            while (i < imageA.count) {

                ((UIImageView *)imageA[i]).transform =
CGAffineTransformMakeTranslation(-5, -2);

                i++;

            }

        }completion:^(BOOL finished) {

         [launchView removeFromSuperview];

        }];

    }];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐