更改FBSDKLoginButton的默认标题

hal*_*ano 1 facebook ios facebook-ios-sdk

问题非常具体.

有没有办法更改FBSDKLoginButton类的默认英文标题"使用Facebook登录"?

在类实现中我已经看到LoginButton.LogInLong是字符串的键,但是我没有运气将键添加到我自己的国际化文件中.此外,我试图在故事板上使用UIButton的title属性,但这不起作用.

我在类的实现文件中发现了这两个方法:

- (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");
}
Run Code Online (Sandbox Code Playgroud)

任何帮助都非常感谢.

bux*_*xik 5

您可以通过覆盖'setTitle'函数(Swift版本)扩展FBSDKLoginButton并设置title:

import Foundation
import FBSDKLoginKit

class MyFBLoginButton: FBSDKLoginButton {

    override func setTitle(_ title: String?, for state: UIControlState) {
        super.setTitle("YOUR CUSTOM FACEBOOK TITLE", forState: state)
    }
}
Run Code Online (Sandbox Code Playgroud)

然后在故事板中使用您自己的facebook按钮类或以编程方式添加按钮