这个小类的主要目的是为你的 App Store 截图创建一个完美的状态栏。
最简单的方法是使用 CocoaPods - 简单地将 iOSFakeCarrier pod 安装到你的项目中。然后在 applicationDidFinishLaunching
中添加这个代码块
NSDateComponents* dateCom = [[NSDateComponents alloc] init];
dateCom.hour = 13;
dateCom.minute = 22;
[XCDFakeCarrier setLocalizedStatusBarWithTime:dateCom];
这将在状态栏中设置时间为 13:22(或者如果你在美国为下午1:22)。时间是本地化的 - 根据你的语言设置。这个 setLocalizedStatusBarWithTime
也会根据语言设置自动添加运营商名称 - 例如在美国是 AT&T,在德国是 T-Mobile DE 等等。欢迎向其他国家/语言添加带有运营商信息的 pull request,目前只有少数几个。
您可以使用其他方法来微调您的状态栏。有像这样的方法
// status bar customizations
/* 0 to 5 */
+ (void)setCellStrength:(int)cellStrength;
/* 0 to 3 */
+ (void)setWiFiStrength:(int)wifiStrength;
/*
dataNetworkType:
0 - GPRS
1 - E (EDGE)
2 - 3G
3 - 4G
4 - LTE
5 - Wi-Fi
6 - Personal Hotspot
7 - 1x
8 - Blank
*/
+ (void)setNetworkType:(int)networkType;
/*
itemIsEnabled:
1 - do not disturb
2 - airplane mode
3 - cell signal strength indicator
6 - show time on right side
10 - strange battery symbol
11 - Bluetooth
12 - strange telephone symbol
13 - alarm clock
13 - slanted plus sign
16 - location services
17 - orientation lock
19 - AirPlay
20 - microphone
21 - VPN
22 - forwarded call?
23 - spinning activity indicator
24 - square
*/
+ (void)setEnabled:(BOOL)enabled atIndex:(NSInteger)index;
/*
Sets carrier to specific string
*/
+ (void)setFakeCarrier:(NSString*) newCarrier;
/*
Sets time info to specific string
*/
+ (void)setFakeTime:(NSString*) newFakeTime;
要将其从生产构建中删除此模块。不仅你的客户不会对你的带有奇怪的运营商信息和“冻结”的错误时间的状态栏感到满意,而且它还很难通过 App Store 审查。我们添加了当使用这个类时的编译警告。理想情况下,为截图创建或至少创建不同的目标 IFDEF
此类。
欢迎向项目中添加新语言,然后在 FakeiOSLocalized.strings 中添加 fakeCarrier 键。新国家将在合并 pull request 后支持新版本。
状态栏代码的核心是从 https://gist.github.com/0xced/3035167 衍生而来。版权所有 (c) 2012-2013 Cédric Luthi / @0xced。我使用了修改版的带有附加方法的版本来自 https://github.com/ksuther/StatusBarCustomization.git,并将其修改为与最新的 iOS 兼容。
更多信息也可以在我的博客文章中找到:http://www.tappytaps.com/blog/developer/nice-status-bar-for-app-store-screenshots/