Swi*_*yJD 6 facebook-graph-api ios facebook-ios-sdk swift
我有他们SDK的facebook登录按钮,想要更改文本.我试过这段代码:
facebookButton.setTitle("my text here", forState: .Normal)
Run Code Online (Sandbox Code Playgroud)
但它不起作用.有办法吗?
这是facebook登录按钮代码的样子:
//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")
}
Run Code Online (Sandbox Code Playgroud)
And*_*lva 12
我刚刚在访问了许多错误的答案后发现它是:
let buttonText = NSAttributedString(string: "your text here")
facebookButton.setAttributedTitle(buttonText, for: .normal)
Run Code Online (Sandbox Code Playgroud)
您可以尝试通过进入 FBLoginViews -如何自定义 FBLoginVIew 来更改按钮文本?
但是,如果您只需用自己的自定义按钮替换该按钮就会容易得多。
此链接可以更好地帮助您: https ://developers.facebook.com/docs/facebook-login/ios#custom-login-button
| 归档时间: |
|
| 查看次数: |
4496 次 |
| 最近记录: |