I have a facebook login button from their SDK and would like to change the text. I've tried this code:
facebookButton.setTitle("my text here", forState: .Normal)
but it doesn't work. Is there a way to do it?
This is what the facebook login button code looks like:
//MARK: Facebook Login
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil {
facebookAPILogin(FBSDKAccessToken.currentAccessToken().tokenString, completionHandler: { error in
if error == nil {
self.performSegueWithIdentifier("loginToHomeSegue", sender: self)
} else {
self.showAlertWithTitle("Sorry".localized(), message: "There was a problem connecting with Facebook".localized() )
print(error)
}
}
)
} else {
showAlertWithTitle("Sorry".localized(), message: "There was a problem connecting with Facebook".localized() )
print(error.localizedDescription)
}
}
//Facebook Logout
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("User logged out")
}
I just found out, after visiting lots of wrong answers, that it is:
let buttonText = NSAttributedString(string: "your text here")
facebookButton.setAttributedTitle(buttonText, for: .normal)
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