- PageHelper返回参数详解
- Java 简介
- Java开发环境配置
- Java基础语法
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章iOS获取AppIcon and LaunchImage's name(app图标和启动图片名字)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
在某种场景下,可能我们需要获取app的图标名称和启动图片的名称。比如说app在前台时,收到了远程通知但是通知栏是不会有通知提醒的,这时我想做个模拟通知提示,需要用到icon名称;再比如在加载某个控制器时,想设置该控制器的背景图片为启动图片,需要用到启动图片名称.
而事实上icon图片放在系统AppIcon文件夹里,启动图片放在系统LaunchImage文件夹里,取这些图片的名称和其他一般资源图片名称不一样.
为了方便举例子,咱们先简单粗暴点 。
假设当前项目只支持iPhone设备,并且只支持竖屏;而且当前项目里已经设置好了AppIcon图标和启动图片, 。
如何获取icon图标名称和启动图片名称呢 ?
上代码和打印日志:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/** 获取app的icon图标名称 */
- (
void
)getAppIconName{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取app中所有icon名字数组
NSArray *iconsArr = infoDict[@
"CFBundleIcons"
][@
"CFBundlePrimaryIcon"
][@
"CFBundleIconFiles"
];
//取最后一个icon的名字
NSString *iconLastName = [iconsArr lastObject];
//打印icon名字
NSLog(@
"iconsArr: %@"
, iconsArr);
NSLog(@
"iconLastName: %@"
, iconLastName);
/*
打印日志:
iconsArr: (
AppIcon29x29,
AppIcon40x40,
AppIcon60x60
)
iconLastName: AppIcon60x60
*/
}
/** 获取app的启动图片名称,并设置为本控制器背景图片 */
- (
void
)getLaunchImageName{
NSString *launchImageName = @
""
;
//启动图片名称变量
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
//获取与当前设备匹配的启动图片名称
if
(screenHeight ==
480
){
//4,4S
launchImageName = @
"LaunchImage-700"
;
}
else
if
(screenHeight ==
568
){
//5, 5C, 5S, iPod
launchImageName = @
"LaunchImage-700-568h"
;
}
else
if
(screenHeight ==
667
){
//6, 6S
launchImageName = @
"LaunchImage-800-667h"
;
}
else
if
(screenHeight ==
736
){
// 6Plus, 6SPlus
launchImageName = @
"LaunchImage-800-Landscape-736h"
;
}
if
(launchImageName.length <
1
)
return
;
//设备启动图片为控制器的背景图片
UIImage *img = [UIImage imageNamed:launchImageName];
self.view.backgroundColor = [UIColor colorWithPatternImage:img];
}
|
打印当前只支持iPhone设备并且只支持竖屏场景下的所有启动图片信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/** 打印app里面所有启动图片名称信息 */
- (
void
)printAllLaunchImageInfo{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取所有启动图片信息数组
NSArray *launchImagesArr = infoDict[@
"UILaunchImages"
];
NSLog(@
"launchImagesArr: %@"
, launchImagesArr);
/*
打印日志:启动图片的名字是固定的
launchImagesArr: (
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Portrait-736h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Landscape-736h";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-667h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{375, 667}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 480}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-568h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
}
)
*/
}
|
看到了,项目AppIcon图标和启动图片信息,都可以从 [[NSBundle mainBundle] infoDictionary] 获得,当前这里面还包含了app的其他信息如版本、app名称、设备类型、支持方向。。.
打印所有信息看看:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/** 打印app工程配置信息 */
- (
void
)printInfoDictionary{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSLog(@
"%@"
, infoDict);
/*
打印日志:
{
BuildMachineOSBuild = 15G31;
CFBundleDevelopmentRegion = en;
CFBundleExecutable = TanTest;
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
AppIcon29x29,
AppIcon40x40,
AppIcon60x60
);
};
};
CFBundleIdentifier = "net.tan.xxx";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleInfoPlistURL = "Info.plist -- file:///Users/PX/Library/Developer/CoreSimulator/Devices/7020368B-C160-42C0-B3C5-5F958FA82EF5/data/Containers/Bundle/Application/77D8C333-A6AF-4183-B79A-A5BEDCD08E1A/TanTest.app/";
CFBundleName = TanTest;
CFBundleNumericVersion = 16809984;
CFBundlePackageType = APPL;
CFBundleShortVersionString = "1.0";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneSimulator
);
CFBundleVersion = 1;
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = "";
DTPlatformName = iphonesimulator;
DTPlatformVersion = "9.3";
DTSDKBuild = 13E230;
DTSDKName = "iphonesimulator9.3";
DTXcode = 0731;
DTXcodeBuild = 7D1014;
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "6.0";
UIDeviceFamily = (
);
UILaunchImageFile = LaunchImage;
UILaunchImages = (
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Portrait-736h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Landscape-736h";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-667h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{375, 667}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 480}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-568h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
}
);
UILaunchStoryboardName = LaunchScreen;
UIMainStoryboardFile = Main;
UIRequiredDeviceCapabilities = (
armv7
);
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait
);
}
*/
}
|
---------- 接下来我们再来在app既支持iPhone和iPad设备,又支持横屏和竖屏时,AppIcon和LaunchImage是怎样的以及如何获取 --- 。
先上两张图,再上测试代码:
测试代码:
1、获取AppIcon所有icon图标名称 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/** 支持iPhone和iPad, 获取app的icon图标名称 */
- (
void
)getAppIconName{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取app中所有icon名字数组
NSArray *iconsArr = infoDict[@
"CFBundleIcons"
][@
"CFBundlePrimaryIcon"
][@
"CFBundleIconFiles"
];
//取最后一个icon的名字
NSString *iconLastName = [iconsArr lastObject];
//打印icon名字
NSLog(@
"iconsArr: %@"
, iconsArr);
NSLog(@
"iconLastName: %@"
, iconLastName);
/*
打印日志(29pt和40pt iPhone和iPad都用到;60pt --- iPhone, 76pt和83.5pt --- iPad):
iconsArr: (
AppIcon29x29,
AppIcon40x40,
AppIcon60x60,
AppIcon76x76,
"AppIcon83.5x83.5"
)
iconLastName: AppIcon83.5x83.5
*/
}
|
2、获取在支持iPhone和iPad开发,支持横屏和竖屏时,获取启动图片,并设为背景图片代码 。
(iPhone设备只有在Plus, 即5.5英寸才有竖屏和横屏两套图片,其他4、5、6竖屏横屏共用一张启动图片) 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/**
支持iPhone和iPad, 支持横屏、竖屏,
获取app的启动图片名称,并设置为本控制器背景图片
*/
- (
void
)getLaunchImageName{
NSString *launchImageName = @
""
;
//启动图片名称变量
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
//屏幕高度
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
//屏幕宽度
//设备界面方向
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
BOOL isPortrait = UIInterfaceOrientationIsPortrait(orientation);
// 是否竖屏
BOOL isLandscape = UIInterfaceOrientationIsLandscape(orientation);
//是否横屏
//获取与当前设备匹配的启动图片名称
//4、4S 竖屏,横屏
if
((isPortrait && screenHeight ==
480
) || (isLandscape && screenWidth ==
480
)){
launchImageName = @
"LaunchImage-700"
;
}
//5、5C、5S、iPod 竖屏,横屏
else
if
((isPortrait && screenHeight ==
568
) || (isLandscape && screenWidth ==
568
)){
launchImageName = @
"LaunchImage-700-568h"
;
}
//6、6S 竖屏,横屏
else
if
((isPortrait && screenHeight ==
667
) || (isLandscape && screenWidth ==
667
)){
launchImageName = @
"LaunchImage-800-667h"
;
}
//6Plus、6SPlus竖屏
else
if
(isPortrait && screenHeight ==
736
){
launchImageName = @
"LaunchImage-800-Portrait-736h"
;
}
//6Plus、6SPlus 横屏
else
if
(isLandscape && screenWidth ==
736
){
launchImageName = @
"LaunchImage-800-Landscape-736h"
;
}
//iPad 竖屏
else
if
(isPortrait && screenHeight ==
1024
){
launchImageName = @
"LaunchImage-700-Portrait"
;
}
//iPad 横屏
else
if
(isLandscape && screenWidth ==
1024
){
launchImageName = @
"LaunchImage-700-Landscape"
;
}
if
(launchImageName.length <
1
)
return
;
//设备启动图片为控制器的背景图片
UIImage *img = [UIImage imageNamed:launchImageName];
self.view.backgroundColor = [UIColor colorWithPatternImage:img];
}
|
3、打印出所有启动图片信息 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/** 打印app里面所有启动图片名称信息 */
- (
void
)printAllLaunchImageInfo{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取所有启动图片信息数组
NSArray *launchImagesArr = infoDict[@
"UILaunchImages"
];
NSLog(@
"launchImagesArr: %@"
, launchImagesArr);
/*
打印日志:启动图片的名字是固定的
launchImagesArr: (
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Portrait-736h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Landscape-736h";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-667h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{375, 667}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 480}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-568h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-Portrait";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{768, 1024}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-Landscape";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{768, 1024}";
}
)
*/
}
|
4、打印所有配置信息 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/** 打印app工程配置信息 */
- (
void
)printInfoDictionary{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSLog(@
"%@"
, infoDict);
/*
打印日志:
{
BuildMachineOSBuild = 15G31;
CFBundleDevelopmentRegion = en;
CFBundleExecutable = TanTest;
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
AppIcon29x29,
AppIcon40x40,
AppIcon60x60,
AppIcon76x76,
"AppIcon83.5x83.5"
);
};
};
CFBundleIdentifier = "net.tan.xxx";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleInfoPlistURL = "Info.plist -- file:///Users/PX/Library/Developer/CoreSimulator/Devices/3246F9AE-1D73-4E4F-8DDF-F591DBE64F63/data/Containers/Bundle/Application/7DD6C793-F882-43CF-9897-1433411289E6/TanTest.app/";
CFBundleName = TanTest;
CFBundleNumericVersion = 16809984;
CFBundlePackageType = APPL;
CFBundleShortVersionString = "1.0";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneSimulator
);
CFBundleVersion = 1;
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = "";
DTPlatformName = iphonesimulator;
DTPlatformVersion = "9.3";
DTSDKBuild = 13E230;
DTSDKName = "iphonesimulator9.3";
DTXcode = 0731;
DTXcodeBuild = 7D1014;
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "9.0";
UIDeviceFamily = (
1,
);
UILaunchImageFile = LaunchImage;
UILaunchImages = (
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Portrait-736h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-Landscape-736h";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{414, 736}";
},
{
UILaunchImageMinimumOSVersion = "8.0";
UILaunchImageName = "LaunchImage-800-667h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{375, 667}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 480}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-568h";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{320, 568}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-Portrait";
UILaunchImageOrientation = Portrait;
UILaunchImageSize = "{768, 1024}";
},
{
UILaunchImageMinimumOSVersion = "7.0";
UILaunchImageName = "LaunchImage-700-Landscape";
UILaunchImageOrientation = Landscape;
UILaunchImageSize = "{768, 1024}";
}
);
UILaunchStoryboardName = LaunchScreen;
UIMainStoryboardFile = Main;
UIRequiredDeviceCapabilities = (
armv7
);
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
}*/
}
|
以上所述是小编给大家介绍的iOS获取AppIcon and LaunchImage's name(app图标和启动图片名字),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我网站的支持! 。
最后此篇关于iOS获取AppIcon and LaunchImage's name(app图标和启动图片名字)的文章就讲到这里了,如果你想了解更多关于iOS获取AppIcon and LaunchImage's name(app图标和启动图片名字)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我在 Xcassets 中编辑一些文件时不小心删除了 LaunchImage 文件集。我该如何取回它!? 我尝试查看目标,使用 xcassets 作为包含图像的文件夹的选项不再存在。 最佳答案 我四处
我删除了原来的 launchImage 图像集。 然后转到 Xcode 项目部分中的“App Icons and Launch Images”。 我取消选择“启动图像源”,然后重新选择它。我得到“将启
无论我尝试什么,我都无法在我的应用程序上显示启动图像。 就上下文而言,这是一个全新的 100% SwiftUI 项目,并且还处于起步阶段。 一切构建和运行都非常好,但我无法进行任何启动图像自定义...
我找不到启动图像的本地化属性。这是否已从 Xcode 中删除? 最佳答案 我认为 LaunchImage 的本地化是不可能的。不过,您可以考虑使用 Launch Storyboard 并获得充分的灵
我的 iPhone Xcode 5.1 项目中有 LaunchImage.png 文件。我已在 app .plist 文件中添加了 LaunchImage.png 。我已将此文件拖放到 LaunchI
我不知道为什么我的 LaunchImage 没有运行。这里有两张图片清楚地表明我做了正确的事情(我希望 :P ) 最佳答案 我也遇到过这个问题。为了让我的启动图像正常工作,我必须让字段 Launch
有没有办法在导航到 Storyboard入口点 Controller 之前以编程方式定义 launchImage 出现的时间? 我希望只有在核心数据异步加载完成 block 之后才能退出启动画面,以确
我使用 launchImage 集来启动我的应用程序,而不是 .xib。在 AppDelegate.swift 中,我设置了一个 NSThread.sleepForTimeInterval(2.0)
这可能没有故障吗? 我的 Xcode 项目有一个在 Assets (又名 Images.xcassets)中定义的启动图像,包括。所有支持的尺寸和方向。因为我想在我的初始 View 中使用相同的图像作
在某种场景下,可能我们需要获取app的图标名称和启动图片的名称。比如说app在前台时,收到了远程通知但是通知栏是不会有通知提醒的,这时我想做个模拟通知提示,需要用到icon名称;再比如在加载某个控制
我的 tvOS 应用程序没有或不需要正确的登录屏幕,但我确实有一个在首次启动时从 AppDelegate 调用的检查。我遇到的问题是,当我的后端发生 checkUser 时,整个应用程序变成了银色。我
如果我的应用仅处于纵向模式且仅适用于 iPhone,如果使用启动图像 Assets ,我是否需要指定所有图像? IE。我需要横向图像还是 iPad 图像,或者没有它们也能工作吗? 最佳答案 如果您的应
我在 xamarin ios 工作。我发现使用 Assets 中的 LaunchImages 和使用 LaunchScreen 之间存在差异。当我使用 LaunchImages 时,我觉得 UI 几乎
我正在开发适用于 iOS/Android 的移动应用程序。我使用的是 Visual Studio Community for Mac 版本 8.1.5,该项目最初创建为新的选项卡式表单 Xamarin
当我转到 Archive my app 并检查 Window -> Organizer -> Archives 时,我的应用程序没有图像: 我转到我的 Apps General 选项卡,看到 Laun
我想控制启动图像何时隐藏在 ios 设备上。我已将“手动隐藏”设置为 true,但没有任何改变。启动图像在启动后不久自行淡出。我使用插件(2.6)和平台(2.2.3)的所有最新版本。如果我将启动图像模
我最近将应用程序的部署目标从 iOS8 更改为 iOS7,现在我在 Xcode 中看到此警告:使用启动屏幕文件并定位 iOS 7.1 及更早版本的应用程序还需要在 Assets 中包含启动图像目录。
我在 iOS 8 和 7 上使用 Xcode 6,我有一个 Launchscreen.xib,在 General Target 中我已经很好地配置了我的项目: http://i.imgur.com/c
我想在 Xcode 中验证我的应用程序,但由于某些奇怪的原因它一直失败,并告诉我: iTunes Store operation failed Your binary is not optimized
我正在使用 Xcode 5 的 Assets 目录,并且我想使用我的 LaunchImage 作为我的主视图的背景图像(从“正在加载”到“已加载”的一种非常常见的做法' 看起来很光滑)。 我想在 As
我是一名优秀的程序员,十分优秀!