iOS10.3新增了更换备用icon的API
// Pass `nil` to use the primary application icon. The completion handler will be invoked asynchronously on an arbitrary background queue; be sure to dispatch back to the main queue before doing any further UI work.
- (void)setAlternateIconName:(nullable NSString *)alternateIconName completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler NS_EXTENSION_UNAVAILABLE("Extensions may not have alternate icons") API_AVAILABLE(ios(10.3), tvos(10.2));
实现步骤
- 配置Info.plist文件
因为要实现轮换icon,所以需要准备两个icon图片,icon、icon2均为图片名称
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>icon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon</string>
</array>
</dict>
<key>icon2</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon2</string>
</array>
</dict>
</dict>
</dict>
- 代码实现
if ([[UIApplication sharedApplication].alternateIconName isEqualToString:@"icon2"]) {
[[UIApplication sharedApplication] setAlternateIconName:@"icon" completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"set AlternateIcon error: %@",error.description);
}
}];
}else{
[[UIApplication sharedApplication] setAlternateIconName:@"icon2" completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"set AlternateIcon error: %@",error.description);
}
}];
}
同样,iOS10.3也更新了AppStore评分系统API
/** Controller class to request a review from the current user */
SK_EXTERN_CLASS_AVAILABLE(10_3) __TVOS_UNAVAILABLE @interface SKStoreReviewController : NSObject
/** Request StoreKit to ask the user for an app review. This may or may not show any UI.
*
* Given this may not succussfully present an alert to the user, it is not appropriate for use
* from a button or any other user action. For presenting a write review form, a deep link is
* available to the App Store by appending the query params "action=write-review" to a product URL.
*/
+ (void)requestReview;
代码实现
[SKStoreReviewController requestReview];