Swift开发:如何为SKStoreReviewController设置自定义标题?

SKStoreReviewController 自定义标题及弹窗实现方案
核心结论:SKStoreReviewController无法自定义标题
苹果提供的SKStoreReviewController系统评分弹窗,完全不支持自定义标题、文案或样式。这个组件是苹果统一管控的,目的是保证所有App的评分弹窗体验一致,防止开发者通过诱导性内容干扰用户判断,所以官方没有开放任何自定义接口,你查不到解决方案是正常的。
实现类似自定义弹窗的可行方案
如果想要做出图中这种自定义样式的弹窗,只能自己手动实现弹窗视图,再结合系统评分逻辑完成流程:
1. 自己实现自定义弹窗
用UIKit或SwiftUI搭建符合需求的弹窗,标题、文案、按钮样式都可以完全自定义,比如:
SwiftUI简化示例代码:
struct CustomReviewPopup: View { @Binding var isShowing: Bool var body: some View { VStack(spacing: 24) { // 自定义标题 Text("喜欢这款App吗?") .font(.title) .fontWeight(.semibold) // 自定义描述文案 Text("您的好评是我们更新的最大动力!") .font(.subheadline) .multilineTextAlignment(.center) .foregroundColor(.secondary) HStack(spacing: 16) { Button("以后再说") { isShowing = false } .buttonStyle(.bordered) Button("去评分") { isShowing = false startReviewProcess() } .buttonStyle(.borderedProminent) } } .padding(24) .background(Color.white) .cornerRadius(16) .shadow(color: .black.opacity(0.1), radius: 10, x: 0, y: 4) } private func startReviewProcess() { // 触发系统评分弹窗(苹果会根据规则决定是否展示) if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene { SKStoreReviewController.requestReview(in: scene) } } }
UIKit简化示例代码(OC):
// 自定义弹窗ViewController @interface CustomReviewPopupVC : UIViewController @property (nonatomic, copy) void(^onReviewTap)(void); @end @implementation CustomReviewPopupVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5]; // 弹窗内容容器 UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(40, 200, self.view.bounds.size.width-80, 220)]; contentView.backgroundColor = [UIColor whiteColor]; contentView.layer.cornerRadius = 16; [self.view addSubview:contentView]; // 自定义标题 UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, contentView.bounds.size.width-40, 40)]; titleLabel.text = @"喜欢这款App吗?"; titleLabel.font = [UIFont boldSystemFontOfSize:20]; titleLabel.textAlignment = NSTextAlignmentCenter; [contentView addSubview:titleLabel]; // 描述文案 UILabel *descLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 70, contentView.bounds.size.width-40, 60)]; descLabel.text = @"您的好评是我们更新的最大动力!"; descLabel.font = [UIFont systemFontOfSize:14]; descLabel.textColor = [UIColor secondaryLabelColor]; descLabel.numberOfLines = 0; descLabel.textAlignment = NSTextAlignmentCenter; [contentView addSubview:descLabel]; // 按钮 UIButton *laterBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, 150, 120, 44)]; [laterBtn setTitle:@"以后再说" forState:UIControlStateNormal]; [laterBtn setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal]; [laterBtn addTarget:self action:@selector(dismissPopup) forControlEvents:UIControlEventTouchUpInside]; [contentView addSubview:laterBtn]; UIButton *reviewBtn = [[UIButton alloc] initWithFrame:CGRectMake(contentView.bounds.size.width-140, 150, 120, 44)]; [reviewBtn setTitle:@"去评分" forState:UIControlStateNormal]; [reviewBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; reviewBtn.backgroundColor = [UIColor systemBlueColor]; reviewBtn.layer.cornerRadius = 8; [reviewBtn addTarget:self action:@selector(triggerReview) forControlEvents:UIControlEventTouchUpInside]; [contentView addSubview:reviewBtn]; } - (void)dismissPopup { [self dismissViewControllerAnimated:YES completion:nil]; } - (void)triggerReview { [self dismissPopup]; if (self.onReviewTap) { self.onReviewTap(); } } @end // 调用弹窗 CustomReviewPopupVC *popup = [[CustomReviewPopupVC alloc] init]; popup.modalPresentationStyle = UIModalPresentationOverFullScreen; popup.onReviewTap = ^{ UIWindowScene *scene = (UIWindowScene *)[UIApplication sharedApplication].connectedScenes.allObjects.firstObject; [SKStoreReviewController requestReviewInScene:scene]; }; [self presentViewController:popup animated:YES completion:nil];
2. 合理控制弹窗展示时机
不要频繁弹出骚扰用户,建议在用户完成核心操作(比如完成3次使用、使用满7天)后再展示,同时记录弹窗展示的时间间隔,避免短时间内重复触发。
3. 备用方案:引导到App Store详情页
如果系统评分弹窗因为苹果的调用频率限制(每年最多展示3次)没有弹出,可以引导用户直接跳转到App Store的App详情页进行评分:
func openAppStoreReviewPage() { guard let appID = "你的AppID" else { return } let reviewURL = URL(string: "itms-apps://itunes.apple.com/app/id\(appID)?action=write-review")! UIApplication.shared.open(reviewURL) }
注意事项
- 自定义弹窗的文案要真实客观,不能用诱导性语言(比如“好评送福利”),避免违反App Store审核规范
SKStoreReviewController.requestReview()的展示完全由苹果控制,即使调用也不一定会弹出弹窗- 自定义弹窗的样式要和你的App整体风格统一,保证用户体验连贯
内容的提问来源于stack exchange,提问作者akiyama
相关产品推荐
相关产品推荐

