调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
销售收入
平台和交易市场
资金管理
开发人员资源
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例Managed Payments
使用 Payment Link
构建结账页面
构建高级集成
构建应用内集成
    概览
    支付表单
      接受应用内支付
      添加自定义支付方式
      自定义外观样式
      在服务器上确认付款
      支付过程中保存付款详情
      设置未来付款
      筛选银行卡品牌
    嵌入式 Payment Element
    应用内购买外部链接
    收集地址
    美国和加拿大卡
支付方式
添加支付方式
管理支付方式
用 Link 更快结账
支付接口
Payment Links
结账
Web Elements
应用内 Element
支付场景
处理多种货币
自定义支付流程
灵活收单
编排
线下支付
Terminal
超越支付功能
成立公司
加密货币
Financial Connections
Climate
首页付款Build an in-app integrationPayment Sheet

自定义外观

使用 Appearance API 自定义您的移动集成。

移动 Payment Element 支持视觉自定义,使您可以匹配应用程序的设计。布局保持一致,但您可以通过在您的 [PaymentSheet 上使用外观属性来修改颜色、字体等。配置](https://stripe.dev/stripe-ios/stripe-paymentsheet/Classes/PaymentSheet/Configuration.html) 对象。

  1. 先开始自定义字体
  2. 自定义颜色以匹配您的应用程序
  3. 自定义形状,如边框半径
  4. 微调特定组件
var configuration = PaymentSheet.Configuration() // The following code creates the appearance shown in the screenshot above var appearance = PaymentSheet.Appearance() appearance.font.base = UIFont(name: "AvenirNext-Regular", size: UIFont.systemFontSize)! appearance.cornerRadius = 12 appearance.shadow = .disabled appearance.borderWidth = 0.5 appearance.colors.background = .white appearance.colors.primary = UIColor(red: 36/255, green: 36/255, blue: 47/255, alpha: 1) appearance.colors.textSecondary = .black appearance.colors.componentPlaceholderText = UIColor(red: 115/255, green: 117/255, blue: 123/255, alpha: 1) appearance.colors.componentText = .black appearance.colors.componentBorder = .clear appearance.colors.componentDivider = UIColor(red: 195/255, green: 213/255, blue: 200/255, alpha: 1) appearance.colors.componentBackground = UIColor(red: 243/255, green: 248/255, blue: 250/247, alpha: 1) appearance.primaryButton.cornerRadius = 20 configuration.appearance = appearance let paymentSheet = PaymentSheet(/* ... */, configuration: configuration)

字体

通过将 font.base 设置为任何大小和粗细的自定义字体的任何变体来自定义字体。移动 Payment Element 使用自定义字体的字体族,但自行决定大小和粗细。

要增大或减小所有文本的大小,请设置 font.sizeScaleFactor。在显示字体大小之前,我们会将字体大小乘以这个值。如果自定义字体略大于或小于系统字体,这将非常有用。

var configuration = PaymentSheet.Configuration() configuration.appearance.font.base = UIFont(name: "CustomFont-Regular", size: UIFont.systemFontSize) configuration.appearance.font.sizeScaleFactor = 1.15 // Increase the size of all text by 1.15x

颜色

通过修改 Appearance.Colors 中定义的颜色类别来自定义移动 Payment Element 中的颜色。每个颜色类别确定 UI 中一个或多个组件的颜色。例如,primary 定义支付按钮和所选项目(如保存此卡复选框)的颜色。请参阅下图,查看与每个颜色类别关联的一些 UI 元素。

注意

若要支持深色模式,请使用 init(dynamicProvider:) 初始化自定义 UIColors。

形状

除字体和颜色外,您还可以自定义整个移动 Payment Element 中使用的角半径、边框宽度和阴影。

特定 UI 组件

以上各节介绍了跨多个 UI 组件广泛影响移动 Payment Element 的自定义选项。我们还专门为主按钮(例如支付按钮)提供了自定义选项。有关自定义选项的完整列表,请参阅 Appearance.PrimaryButton。

特定 UI 组件的自定义选项优先于其他值。例如,appearance.primaryButton.cornerRadius 会覆盖 appearance.cornerRadius 的值。

注意

如认为我们需要添加更多自定义选项,敬请告知。

此页面的内容有帮助吗?
是否
需要帮助?联系支持。
加入我们的早期使用计划。
查看我们的更改日志。
有问题?联系销售。
LLM? Read llms.txt.
Powered by Markdoc