How can I create a custom SignInWithAppleButton that uses only the Apple logo and implements the onRequest and onCompletion logic?

Is there a way to modify the SignInWithAppleButton so that only the Apple logo appears? According to Apple's guidelines, it's permissible to use only the icon. https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple

Unfortunately, the button isn't customizable. However, I need a button that utilizes the logic of onRequest and onCompletion.

Here's my current code using the standard SignInWithAppleButton.

SignInWithAppleButton(.signIn,
     onRequest: { request in
         print("Apple ID Request")
         AppleSignInManager.shared.requestAppleAuthorization(request)
      },
      onCompletion: { result in
         print("Apple ID Completion")
         handleAppleID(result)
      }                  
  )
  .font(.title)
  .signInWithAppleButtonStyle(.white)
  .frame(height: 50)

I tried exploring various SwiftUI customization options for the SignInWithAppleButton, such as adjusting its style or overlaying it with a custom image. I was expecting to find a way to remove the text and display only the Apple logo, as permitted by Apple's guidelines. However, I found that the SignInWithAppleButton isn't easily customizable in this way. So, I'm seeking guidance on alternative approaches to achieve the desired customization while still maintaining the functionality provided by the onRequest and onCompletion handlers.

Replies

There is an instance method in SignInWithAppleButton: dialogIcon(_:).

func dialogIcon(_ icon: Image?) -> some View

Unfortunately, not documented (but some limited info here: https://stackoverflow.com/questions/76860051/how-to-change-the-icon-for-confirmation-dialogs-and-alerts-in-swiftui).

Did you try it ?

unfortunately This modifier has no effect on iOS.