I am implementing ASAuthorizationAppleIDButton - as per Apple's request - but unfortunately my login background is dark and I can't find how to change the button color to a light or white button like the ones Apple show in many of their examples?
This is what I have:
let appleButton = ASAuthorizationAppleIDButton()
override func viewDidLoad() {
super.viewDidLoad()
setAppleButtonStyle()
}
func setAppleButtonStyle() {
if #available(iOS 13.0, *) {
appleButton.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(appleButton)
NSLayoutConstraint.activate([
appleButton.centerYAnchor.constraint(equalTo: facebookLoginView.centerYAnchor, constant: -70),
appleButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
appleButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
appleButton.heightAnchor.constraint(equalToConstant: 50)
])
} else {
//Do Nothing
}
}
Simply provide the desired style
when you instantiate the button instance.
E.g.
let appleButton = ASAuthorizationAppleIDButton(type: .default, style: .white)
This would be what you would use if you were using Objective-C:
ASAuthorizationAppleIDButton *appleIDButton = [ASAuthorizationAppleIDButton buttonWithType:ASAuthorizationAppleIDButtonTypeContinue style:ASAuthorizationAppleIDButtonStyleBlack];
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