I'm using PKPaymentButton for ApplePay integration but want to know if I can customize it easily.
let applePayButton = PKPaymentButton(type: PKPaymentButtonType.setUp, style: PKPaymentButtonStyle.black)
Can we change the button style? After setup of ApplePay, I wanted to change the buttonType to .buy but didn't find a solution.
Can we remove corner radius? Default ApplePay button has corner radius. I don't like it and tried to remove it. So, I tried to work with layer but it didn't work.
applePayButton.layer.cornerRadius = 0
Please let me know if I can change the ApplePay button properties easily.
Yes you can change it by recreating PKPaymentButton with different PKPaymentButtonStyle in runtime. Or you can write your own PKPaymentButton wrapper that will do it for you.
Though Apple doesn't recommend to alter Apple Pay Button appearance, it's doable. Again, using your PKPaymentButton wrapper, place Apple Pay button in the center and alter corner radius of your wrapper button, you can change size of icons in that way too. I did it in some of my projects and didn't get a word from Apple.
You can also change the appearance of the button with his runtime attributes:
[self.applePayButton setValue:@(0) forKey:@"style"];
Pass 0 for a black button and 2 for a white Apple Pay Button
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With