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));
實(shí)現(xiàn)步驟
- 配置Info.plist文件
因?yàn)橐獙?shí)現(xiàn)輪換icon,所以需要準(zhǔn)備兩個(gè)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>
- 代碼實(shí)現(xiàn)
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);
}
}];
}
AlternateIcon screenshot
同樣,iOS10.3也更新了AppStore評分系統(tǒng)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;
代碼實(shí)現(xiàn)
[SKStoreReviewController requestReview];
SKStoreReviewController