更改FBSDKLoginButton的默认标题 [英] Change the default title of FBSDKLoginButton
问题描述
这个问题是具体的。
有没有办法更改FBSDKLoginButton类的默认英文标题用Facebook登录?
Is there a way to change the default english title "Log in with Facebook" for the FBSDKLoginButton class?
在类实现中,我看到LoginButton.LogInLong是字符串的关键字,但我没有运气添加我自己的国际化文件的密钥。此外,我尝试在故事板上使用UIButton的标题属性,但这没有起作用。
Inside the class implementation I've seen that LoginButton.LogInLong is the key for the string but I had no luck adding the key to my own internationalisation file. Also I've tried to use the title attribute for UIButton on the storyboard but this didn't work.
我在课程的实现文件中找到了这两个方法:
I've found this two methods inside the implementation file of the class:
- (NSString *)_longLogInTitle
{
return NSLocalizedStringWithDefaultValue(@"LoginButton.LogInLong", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
@"Log in with Facebook",
@"The long label for the FBSDKLoginButton when the user is currently logged out");
}
- (NSString *)_shortLogInTitle
{
return NSLocalizedStringWithDefaultValue(@"LoginButton.LogIn", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
@"Log in",
@"The short label for the FBSDKLoginButton when the user is currently logged out");
}
任何帮助都非常感激。
Any help is really appreciated.
推荐答案
您可以扩展FBSDKLoginButton并通过覆盖setTitle功能(Swift版本)设置标题:
You can extend FBSDKLoginButton and set title by override 'setTitle' function (Swift version):
import Foundation
import FBSDKLoginKit
class MyFBLoginButton: FBSDKLoginButton {
override func setTitle(title: String?, forState state: UIControlState) {
super.setTitle("YOUR CUSTOM FACEBOOK TITLE", forState: state)
}
}
接下来在故事板中使用自己的facebook按钮类或按程序添加按钮
And next use your own facebook button class in storyboard or add button programitically
这篇关于更改FBSDKLoginButton的默认标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!