KCLaunchImage 0.0.4

KCLaunchImage 0.0.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年9月

kavichen维护。



  • 作者:
  • kavichen

演示

视频演示

说明

一个显示启动图如“知乎日报”的视图控制器。

安装

  1. pod 'KCLaunchImage' 添加到您的 Podfile 中。
  2. 在终端中输入命令 pod install
  3. 完成。

添加到您的项目

  1. KCLaunchImageViewController.hKCLaunchImageViewController.m 添加到您的项目(如果您从 pod 中安装,请跳过此步骤)。
  2. Images.xcassets 下创建一个名为 FakeLaunchImage 的新文件夹。
  3. 创建 4 种类型的图像集

    • FakeLaunchImage-320w-480h@2x (iPhone4)
    • FakeLaunchImage-320w-568h@2x (iPhone5)
    • FakeLaunchImage-375w-667h@2x (iPhone6)
    • FakeLaunchImage-414w-736h@3x (iPhone6P)
  4. 为每个图像集添加一个特定图像

  5. 将您自己的启动图添加到 LaunchImage

  6. 添加名为 displayImage 的自定义显示图像(与 FakeLaunchImage 相同)。
  7. 在您的 AppDelegate.m 文件中,添加以下代码。
\#import "KCLaunchImageViewController.h"
\#import "UIImage+ForiPhone.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIImageView *splashScreen = [[UIImageView alloc] initWithImage:[UIImage autoSelectImageWithImageName:@"FakeLaunchImage"]];
    [self.window addSubview:splashScreen];

    self.window.rootViewController =
    [KCLaunchImageViewController addTransitionToViewController:[[KCViewController alloc] init]
                                          modalTransitionStyle:UIModalTransitionStyleCrossDissolve
                                                     withImageName:@"DisplayImage"
                                                     taskBlock:^(void){
                                                         [splashScreen removeFromSuperview];
                                                     }];
    return YES;
}

资源文件

文件应在 Sketch 中打开

注意

如果你的图像在 images.xcassets 中,请设置 Deployment Target >= 7.0。

作者

kavichen,[email protected]

许可证

KCLaunchImage 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。