0

I successfully customized the login button for web, but how can I do it for iOS? I've been looking and haven't been able to find anything.

I'm currently using the Facebook SDK 3.0 and it was fairly easy to implement, but the design of the FBLoginView button sticks out like a sore thumb. I'm in the process of trying to cover it up with an animated button and forward touches to the real Facebook button behind it.

Will Apple reject this kind of work-around when it gets submitted? There has to be an easier way, no?

KidIcarus271
  • 144
  • 2
  • 9

4 Answers4

1

Possible Duplicate of "How to customize FBLoginVIew?" check both Question & Answer

There have been no reported issues of rejection on customization of Facebook Login View as per my knowledge

Community
  • 1
  • 1
Pranav Jaiswal
  • 3,752
  • 3
  • 32
  • 50
  • I guess this really was a duplicate, that was pretty much identical and it worked! I should have focused my searches around FBLoginView and I probably would have found my answer. Thanks! – KidIcarus271 Sep 13 '12 at 18:27
0

Yes, you can change it by using below code.

    for (id obj in loginview.subviews)
{
    if ([obj isKindOfClass:[UIButton class]])
    {
        UIButton * loginButton =  obj;
        [loginButton setBackgroundColor:[UIColor blueColor]];
        UIImage *loginImage = [UIImage imageNamed:@"facebook_btn~ipad.png"];
        [loginButton setBackgroundImage:loginImage forState:UIControlStateNormal];
        [loginButton setBackgroundImage:nil forState:UIControlStateSelected];
        [loginButton setBackgroundImage:nil forState:UIControlStateHighlighted];
        [loginButton sizeToFit];
    }
    if ([obj isKindOfClass:[UILabel class]])
    {
        UILabel * loginLabel =  obj;
        loginLabel.text = @"Login with facebook";
        loginLabel.textAlignment = NSTextAlignmentCenter;
        loginLabel.frame = CGRectMake(0, 30, 600, 30);
        //loginLabel.text. = [UIFont fontWithName:@"Default" size:30.0];
        [loginLabel setFont:[UIFont boldSystemFontOfSize:27]];
    }
}
ASHISHT
  • 305
  • 1
  • 14
0

Please, read the README file in Facebook SDK. You have to add the Row - FacebookBundleName in info.plist and put it a name for your bundle. Then, add a bundle to your project with this name and put into folders named "lang.lproj": for example: en.lproj - it.lproj - fr.lproj - es.lproj.... Into this folders you have to add the Localizable.strings file, then you can localize a lot of phrases, like:

"FBLV:LogOutButton" = "Log Out";
"FBLV:LogInButton" = "Log In";
"FBLV:LoggedInAs" = "Logged in as: %@";
"FBLV:LoggedInUsingFacebook" = "Logged in using Facebook";
"FBLV:LogOutAction" = "Log Out";
"FBLV:CancelAction" = "Cancel";

Hope it helps you!

Mellaito
  • 11
  • 3
0
//Add the normal button then add your own image and tittle and give the action the button and use the below code in the button action.
NSMutableDictionary *fbResultData;
 FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    [login
     logInWithReadPermissions: @[@"public_profile", @"email", @"user_friends"]
     fromViewController:self
     handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
         if (error) {
             NSLog(@"Process error");
         } else if (result.isCancelled) {
             NSLog(@"Cancelled");
         } else {
             NSLog(@"Logged in");

             if ([FBSDKAccessToken currentAccessToken])
             {

                 [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=id,name,age_range,birthday,devices,email,gender,last_name,family,friends,location,picture" parameters:nil]
                  startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                      if (!error) {

                          NSString * accessToken = [[FBSDKAccessToken currentAccessToken] tokenString];
                          NSLog(@"fetched user:%@ ,%@", result,accessToken);

                          fbResultData =[[NSMutableDictionary alloc]init];

                          if ([result objectForKey:@"email"]) {
                              [fbResultData setObject:[result objectForKey:@"email"] forKey:@"email"];
                          }
                          if ([result objectForKey:@"gender"]) {
                              [fbResultData setObject:[result objectForKey:@"gender"] forKey:@"gender"];
                          }
                          if ([result objectForKey:@"name"]) {
                              NSArray *arrName;
                              arrName=[[result objectForKey:@"name"] componentsSeparatedByString:@" "];

                              [fbResultData setObject:[arrName objectAtIndex:0] forKey:@"name"];
                          }
                          if ([result objectForKey:@"last_name"]) {
                              [fbResultData setObject:[result objectForKey:@"last_name"] forKey:@"last_name"];
                          }
                          if ([result objectForKey:@"id"]) {
                              [fbResultData setObject:[result objectForKey:@"id"] forKey:@"id"];
                          }

                          FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                                        initWithGraphPath:[NSString stringWithFormat:@"me/picture?type=large&redirect=false"]
                                                        parameters:nil
                                                        HTTPMethod:@"GET"];
                          [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                                                id result,
                                                                NSError *error) {
                              if (!error){

                                  if ([[result objectForKey:@"data"] objectForKey:@"url"]) {
                                      [fbResultData setObject:[[result objectForKey:@"data"] objectForKey:@"url"] forKey:@"picture"];
                                  }

                                  //You get all detail here in fbResultData
                                  NSLog(@"Final data of FB login********%@",fbResultData);

                                  self.fullNameTextField.text = [fbResultData objectForKey:@"name"];
                                  self.lastNameTextField.text = [fbResultData objectForKey:@"last_name"];
                                  [_customFaceBookButton setImage:[UIImage imageNamed:@"fb_connected"] forState:UIControlStateNormal];

                              } }];
                      }
                      else {
                          NSLog(@"result: %@",[error description]);
                          AlertView *alert = [[AlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:[error description] delegate:nil cancelButtonTitle:NSLocalizedString(@"DISMISS", nil) otherButtonTitle:nil];
                          [alert showInView:self.view.window];
                      }
                  }];
             }
             else{
                 [[FBSDKLoginManager new] logOut];
                  [_customFaceBookButton setImage:[UIImage imageNamed:@"fb_connected"] forState:UIControlStateNormal];
             }
         }
     }];
Kamalkumar.E
  • 254
  • 2
  • 11