日常sdk接入工作免不了各种闪屏和icon需要设置,但由于xcode升级导致设置方法有不同的变迁,着此记录下ios的设置方法
Icons:
方法一: 早期xcode版本,在Info.plist中设置icons,因不打算再用此方法,具体对应尺寸不在记录 方法二: 设置App Icon Source,widows上可以用convert做切分icon的脚本,mac上推荐 Icon Set Creator免费版,收费版和免费版收费功能并不好用。 附:ios Icon全尺寸
闪屏
方法一:启动图 点击工程目录中的Images.xcassets,点击左侧边栏的LaunchImages Launch Screen File留空 xcode11以后没有Launch Images Source,但可以再setting中设置方法二:启动页面 好处是自适应屏幕,不用挨个拖图 方法三: 很多手游渠道对闪屏适配其实不太关心,可以用代码实现一个简单的图片适配和延迟//添加闪屏,如果有的话
NSString *splashName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"platformID"];
NSString *splashPath = [[NSBundle mainBundle] pathForResource:splashName ofType:@"png"];
if (splashName == NULL || splashPath == NULL){
app->run();
}else{
UIImage *splashImage = [UIImage imageWithContentsOfFile:splashPath];
CGRect rect = [[UIScreen mainScreen] bounds];
UIView* splashView = [[UIView alloc] initWithFrame:rect];
splashView.layer.contents = (id)splashImage.CGImage;
[[viewController view] addSubview:splashView];
//退出闪屏
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [splashView removeFromSuperview];
// cocos2d::CCApplication::sharedApplication()->run();
//淡出闪屏
[UIView animateWithDuration:0.5 animations:^{
splashView.alpha = 0.0;
app->run();
}];
});
}
注意: 此方法遇到执行时出现过,显示icon放大到全屏并且模糊的情况, 实际是因为此代码若splashName为nil,则返回的是Images.xcassets中的第一张图的路径
NSString *splashPath = [[NSBundle mainBundle] pathForResource:splashName ofType:@“png”];