Ios – FacebookSDK(4.1.x) Custom Login UI Button – Swift(1.2)


Following this tutorial, I have managed to make a Facebook Login Button working. However, it is assigning the button image automatically from the SDK and it is not customisable (as it is not getting created on Storyboard), so I am unable to use my own button image or text instead.

I believe this part of the code (in ViewDidLoad) is assigning the button:

        let loginView : FBSDKLoginButton = FBSDKLoginButton()
        self.view.addSubview(loginView) =
        loginView.readPermissions = ["public_profile", "email"]
        loginView.delegate = self

What I need to do is creating a @IBOutlet Button on Storyboard and customise it from there. How can I do that?

Best Solution

Login with custom button and access token.

Get user info in facebook sdk 4.x


@IBAction func btnFBLoginPressed(sender: AnyObject) {
    var fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
    fbLoginManager.logInWithReadPermissions(["email"], fromViewController: self, handler: { (result, error) -> Void in
        if (error == nil){
            var fbloginresult : FBSDKLoginManagerLoginResult = result

func getFBUserData(){
    if((FBSDKAccessToken.currentAccessToken()) != nil){
        FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).startWithCompletionHandler({ (connection, result, error) -> Void in
            if (error == nil){
Related Question