【问题标题】:Stripe framework always returns @1x images for card brandsStripe 框架始终为卡片品牌返回 @1x 图像
【发布时间】:2017-07-04 01:01:05
【问题描述】:

Stripe 总是返回 @1x 卡片品牌的小图片。

我想要的是它应该根据设备分辨率选择 @2x,@3x 图像。

这是我的代码。

let cardBrand = STPCardValidator.brand(forNumber: cardNumber)
let cardImage = STPImageLibrary.brandImage(for: cardBrand)

self.IBImageViewCardType?.image = cardImage

感谢任何帮助。

提前致谢。

【问题讨论】:

    标签: ios swift stripe-payments


    【解决方案1】:

    根据 Stripe,它们将返回大小为 32*20 像素的图像。

    查看文档here

    如果您希望获得更大尺寸的图像,那么您需要创建自己的实现。

    添加较大尺寸的资产,获取卡片类型并设置图像。

    你可以像下面这样实现

    func setImage(_ card : String) {              
                    switch card {
    
                    case CardType.Visa.rawValue:
    
                    case CardType.MasterCard.rawValue:
    
                    case CardType.Amex.rawValue:
    
                    case CardType.JCB.rawValue:
    
                    case CardType.Discover.rawValue:
    
                    case CardType.Diners.rawValue:
    
                    case CardType.Maestro.rawValue:
    
                    case CardType.Electron.rawValue:
    
                    case CardType.Dankort.rawValue:
    
                    case CardType.UnionPay.rawValue:
    
                    case CardType.RuPay.rawValue:
    
    
                    case CardType.Unknown.rawValue:
    
                    default:
    
    
                        break
                    }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-11-16
      • 1970-01-01
      • 2017-11-16
      • 1970-01-01
      • 2015-03-30
      • 1970-01-01
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多