自定义“条款和条件”对话框
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以使用 GMSNavigationTermsDialogUIParams
对象更改背景颜色、字体和文字颜色,从而自定义“条款及条件”对话框的外观和风格。
示例
以下代码示例演示了如何自定义“条款及条件”对话框的外观和风格。
Swift
let termsUIParams = GMSNavigationTermsDialogUIParams(
backgroundColor: .brown,
titleFont: UIFont(name:"ChalkboardSE-Bold", size:18),
titleColor: .orange,
mainTextFont: UIFont(name:"MarkerFelt-Wide", size:18),
mainTextColor: .yellow,
buttonsFont: UIFont(name:"Arial-BoldItalicMT", size:14),
cancelButtonTextColor: .green,
acceptButtonTextColor: .blue)
let termsAndConditionsOptions = GMSNavigationTermsAndConditionsOptions(companyName: "Ride Sharing Co.")
termsAndConditionsOptions.title = "Some Title"
termsAndConditionsOptions.uiParams = termsUIParams
GMSNavigationServices.showTermsAndConditionsDialogIfNeeded(
with: termsAndConditionsOptions) { termsAccepted in
if termsAccepted {
// ...
} else {
// ...
}
}
Objective-C
GMSNavigationTermsDialogUIParams *termsUIParams =
[[GMSNavigationTermsDialogUIParams alloc] initWithBackgroundColor:[UIColor brownColor]
titleFont:[UIFont fontWithName:@"ChalkboardSE-Bold" size:18]
titleColor:[UIColor orangeColor]
mainTextFont:[UIFont fontWithName:@"MarkerFelt-Wide" size:18]
mainTextColor:[UIColor yellowColor]
buttonsFont:[UIFont fontWithName:@"Arial-BoldItalicMT" size:14]
cancelButtonTextColor:[UIColor greenColor]
acceptButtonTextColor:[UIColor blueColor]];
GMSNavigationTermsAndConditionsOptions *termsAndConditionsOptions = [[GMSNavigationTermsAndConditionsOptions alloc] initWithCompanyName:@"Ride Sharing Co."];
termsAndConditionsOptions.title = @"Some Title";
termsAndConditionsOptions.uiParams = termsUIParams;
[GMSNavigationServices
showTermsAndConditionsDialogIfNeededWithOptions:termsAndConditionsOptions
callback:^(BOOL termsAccepted) {
if (termsAccepted) {
// …
} else {
// …
}
}];
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe \u003ccode\u003eGMSNavigationTermsDialogUIParams\u003c/code\u003e object allows customization of the Terms and Conditions dialog's appearance, including background color, fonts, and text colors.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can modify elements like title font, main text font, button font, and respective colors using this object.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples demonstrate how to implement these customizations in both Swift and Objective-C.\u003c/p\u003e\n"]]],["The `GMSNavigationTermsDialogUIParams` object customizes the Terms and Conditions dialog's appearance. You can modify the background color, fonts, and text colors. Create a `GMSNavigationTermsDialogUIParams` instance, setting desired properties like `backgroundColor`, `titleFont`, and button text colors. Then, create `GMSNavigationTermsAndConditionsOptions`, set `uiParams`, company name and the title. Finally, use `GMSNavigationServices.showTermsAndConditionsDialogIfNeeded` to display the dialog and handle user acceptance.\n"],null,["# Customizing the Terms and Conditions Dialog Box\n\nYou can use the `GMSNavigationTermsDialogUIParams` object to customize the look\nand feel of the Terms and Conditions dialog box by changing the background\ncolor, the fonts, and the text colors.\n\nExample\n-------\n\nThe following code example demonstrates how to customize the look and feel of\nthe Terms and Conditions dialog box.\n\n\u003cbr /\u003e\n\n### Swift\n\n\u003cbr /\u003e\n\n let termsUIParams = GMSNavigationTermsDialogUIParams(\n backgroundColor: .brown,\n titleFont: UIFont(name:\"ChalkboardSE-Bold\", size:18),\n titleColor: .orange,\n mainTextFont: UIFont(name:\"MarkerFelt-Wide\", size:18),\n mainTextColor: .yellow,\n buttonsFont: UIFont(name:\"Arial-BoldItalicMT\", size:14),\n cancelButtonTextColor: .green,\n acceptButtonTextColor: .blue)\n\n let termsAndConditionsOptions = GMSNavigationTermsAndConditionsOptions(companyName: \"Ride Sharing Co.\")\n termsAndConditionsOptions.title = \"Some Title\"\n termsAndConditionsOptions.uiParams = termsUIParams\n\n GMSNavigationServices.showTermsAndConditionsDialogIfNeeded(\n with: termsAndConditionsOptions) { termsAccepted in\n if termsAccepted {\n // ...\n } else {\n // ...\n }\n }\n\n\u003cbr /\u003e\n\n### Objective-C\n\n\u003cbr /\u003e\n\n GMSNavigationTermsDialogUIParams *termsUIParams =\n [[GMSNavigationTermsDialogUIParams alloc] initWithBackgroundColor:[UIColor brownColor]\n titleFont:[UIFont fontWithName:@\"ChalkboardSE-Bold\" size:18]\n titleColor:[UIColor orangeColor]\n mainTextFont:[UIFont fontWithName:@\"MarkerFelt-Wide\" size:18]\n mainTextColor:[UIColor yellowColor]\n buttonsFont:[UIFont fontWithName:@\"Arial-BoldItalicMT\" size:14]\n cancelButtonTextColor:[UIColor greenColor]\n acceptButtonTextColor:[UIColor blueColor]];\n\n GMSNavigationTermsAndConditionsOptions *termsAndConditionsOptions = [[GMSNavigationTermsAndConditionsOptions alloc] initWithCompanyName:@\"Ride Sharing Co.\"];\n termsAndConditionsOptions.title = @\"Some Title\";\n termsAndConditionsOptions.uiParams = termsUIParams;\n\n [GMSNavigationServices\n showTermsAndConditionsDialogIfNeededWithOptions:termsAndConditionsOptions\n callback:^(BOOL termsAccepted) {\n if (termsAccepted) {\n // ...\n } else {\n // ...\n }\n }];\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]