Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook IOS SDK Login Button Force Small Text

Is there a way to force the Facebook Login Button so it displays "Log in" as opposed to "Log in with Facebook"? Below is what it looks like on an iPhone 6

enter image description here

And below on an iPhone 6 Plus

enter image description here

I have briefly looked at the Facebook SDK on Github and have failed to come up with a solution. Facebook basically looks at the width of the button then displays the appropriate text. I don't want the text to overrun like it is on the iPhone 6 Plus.

like image 209
TYRONEMICHAEL Avatar asked Dec 24 '22 16:12

TYRONEMICHAEL


2 Answers

There's actually a very easy way to customize the text of a FBSDKLoginButton. Here you go:

var fbButton = FBSDKLoginButton()
var titleText = NSAttributedString(string: "Your new button title")
fbButton.setAttributedTitle(titleText, forState: UIControlState.Normal)
like image 151
Matt Schwartz Avatar answered Dec 27 '22 07:12

Matt Schwartz


From the Facebook docs:

Localizing Facebook Strings

The SDK installer includes a FacebookSDK.strings file that is a localizable as described in Apple's localization guide. You can include the file in your app and localize it like a typical strings file.

You can copy the FacebookSDK.strings file located in the resources directory of the downloaded Facebook sdk and paste it in your project directory. The default string for the key: LoginButton.LogInLong is Log in with Facebook, you can change the string to whatever you like.

like image 34
juanjo Avatar answered Dec 27 '22 06:12

juanjo