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];
}];
}];
}
思路是使用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];
}];
}];
}
相关文章推荐
- 【iOS开发-51】案例学习:动画新写法、删除子视图、视图顺序、延迟方法、按钮多功能用法及icon图标和启动页设置
- 【iOS-Cocos2d游戏开发之二十一 】自定义精灵类并为你的精灵设置攻击帧以及动画创建!【二】 推荐
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现动画进行时慢动作\设置游戏加减速进行
- 【iOS开发-57】案例改进:block动画、控件的removeFromSuperview、利用layer设置圆角矩形以及代理模式运用
- 【深入浅出IOS开发】在UIView中设置动画
- 三种简单的动画设置——IOS
- 【iOS-Cocos2d游戏开发之七】在cocos2d中添加/删除系统组件,并解决View设置透明会影响View中的其他组件的问题!【11月28日更新解决添加组件Cocos2d动画停止播放的BUG】
- iOS开发UI篇—iOS开发中三种简单的动画设置
- iOS icon及启动页的使用和设置
- iOS开发UI篇—iOS开发中三种简单的动画设置
- iOS block-base 动画简单用法+关键帧动画设置线性变化速度的问题
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)! .
- 【iOS-Cocos2d游戏开发之七】在cocos2d中添加/删除系统组件,并解决View设置透明会影响View中的其他组件的问题!更新解决添加组件Cocos2d动画停止播放的BUG】
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)!
- IOS 跳转动画设置以及样式
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)!
- 【iOS-Cocos2d游戏开发之七】在cocos2d中添加/删除系统组件,并解决View设置透明会影响View中的其他组件的问题!【11月28日更新解决添加组件Cocos2d动画停止播放的BUG】
- 【iOS-Cocos2d游戏开发之二十二 】CCSpeed实现CCAnimate动画进行时设置慢动作以及设置游戏加减速进行(塔防游戏必备)!
- iOS开发UI篇—iOS开发中三种简单的动画设置
- iOS 设置启动页停留时间