我在哪里可以找到 Apple Pay 按钮资源?

Posted

技术标签:

【中文标题】我在哪里可以找到 Apple Pay 按钮资源?【英文标题】:Where can I find Apple Pay button resources? 【发布时间】:2018-03-07 23:27:01 【问题描述】:

我正在尝试获取具有自定义高度的 PKPaymentButton,但我尝试的所有操作均不成功。 Apple 的 PKPaymentButton 以 30 的高度约束返回。尝试停用/删除约束并添加我自己的高度没有任何作用。此时,我想尝试使用他们的按钮图像资源。

当前的 Apple Pay 身份指南表明它们可以在 https://developer.apple.com/apple-pay/ 获得,但那里什么也没有。使用网络存档时间机器,(https://web.archive.org/web/20160507141217/https://developer.apple.com/apple-pay/) 下载链接清晰可见,但导致 403 Forbidden。

有人知道这些资源发生了什么吗?或者,如果 Apple 想要强制我们使用 PKPaymentButton,我该如何更改高度并使其正确缩放?

【问题讨论】:

来自Apple Pay Identity Guidelines "对于 ios 8.3 及更高版本,必须仅使用 Apple 提供的 API 创建 Apple Pay 支付按钮。" - 你必须使用PKPaymentButton 你能展示你用来尝试改变按钮大小的代码吗?添加高度约束对我有用。 感谢您指出这一点!我删除了代码,但我所做的只是实例化一个 PKPaymentButton,以编程方式添加高度约束,然后将其添加为视图控制器子视图。我更改了顺序以先将其添加为子视图,然后将其约束以防万一有任何副作用,但这没有任何区别。你能提供你试过的代码吗? 【参考方案1】:

取消那个。解决了。我错过了旧的translatesAutoresizingMasksIntoContraints gotcha。

let applePayButton = PKPaymentButton(paymentButtonType: .buy, paymentButtonStyle: .whiteOutline)
applePayButton.translatesAutoresizingMaskIntoConstraints = false
applePayButton.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:[applePayButton(==300)]", options: [], metrics: nil, views: ["applePayButton": applePayButton]))
applePayButton.addConstraint(NSLayoutConstraint(item: applePayButton, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 100))

controller.view.addSubview(applePayButton)

【讨论】:

以上是关于我在哪里可以找到 Apple Pay 按钮资源?的主要内容,如果未能解决你的问题,请参考以下文章

Flutter:如何根据 Apple 指南添加 Apple Pay 按钮

Apple Pay - “付款未完成” - 使用 Stripe

苹果手机还原所有设置后apple pay里的卡没了怎么找到?

使用 React Native 的 Apple Pay

苹果手机还原所有设置后apple pay里的卡没了怎么找到?

php WooCommerce:将Apple Pay按钮移至客户详细信息表单下方