Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Apple Pay - Customize PKPaymentButton

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)
  1. Can we change the button style? After setup of ApplePay, I wanted to change the buttonType to .buy but didn't find a solution.

  2. 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.

like image 437
Castor Avatar asked Mar 10 '26 02:03

Castor


2 Answers

  1. 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.

  2. 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.

like image 181
Ivan Kvyatkovskiy Avatar answered Mar 12 '26 17:03

Ivan Kvyatkovskiy


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

like image 20
Beeke Avatar answered Mar 12 '26 18:03

Beeke