更改FBSDKLoginButton的默认标题

这个问题真的很具体。

有没有办法改变FBSDKLoginButton类的默认英文标题“使用Facebooklogin”?

在类的实现里面我已经看到LoginButton.LogInLong是string的关键字,但是我没有把自己的国际化文件添加到密钥中。 另外我试图在故事板上使用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"); } 

任何帮助真的很感激。

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

 import Foundation import FBSDKLoginKit class MyFBLoginButton: FBSDKLoginButton { override func setTitle(title: String?, forState state: UIControlState) { super.setTitle("YOUR CUSTOM FACEBOOK TITLE", forState: state) } } 

接下来在故事板中使用您自己的Facebookbutton类或以编程方式添加button

您可以使用自己的button进行Facebooklogin,并将下面的代码放在button触摸操作中

 - (IBAction)buttonLoginWithFacebookTapped:(UIButton *)sender { FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeClear]; [login logInWithReadPermissions:@[@"email",@"public_profile"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error) { NSLog(@"error: %@", [error localizedDescription]); } else if (result.isCancelled) { NSLog(@"error: Facebook Login Process Cancelled"); } else { NSLog(@"signed auth token - %@ \n %@",result.token,[FBSDKAccessToken currentAccessToken]); } }]; }