How to customize FBLoginVIew?

后端 未结 17 848
暗喜
暗喜 2020-12-02 05:56

In order to connect to facebook in my ios app i\'m using FBLoginVIew from Facebook SDK for iOS.

It shows a nice FB Login Button, but I want to use my own image and t

17条回答
  •  长情又很酷
    2020-12-02 06:41

    I wanted to be FBLoginview shows as a UIBarbutton, So i have made a simple approach:

    First i've added FBLoginView as a property:

    @property (nonatomic, strong) FBLoginView* loginView;
    

    And then i've added the login view outside the view:

        self.loginView = [[FBLoginView alloc] init];
        self.loginView.frame = CGRectMake(-500, -500, 0, 0);
        [self.view addSubview:self.loginView];
        self.loginView.delegate = self;
    

    And then, i've added a standard system UIbarbuttonItem

        UIBarButtonItem* fbButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(fireFbLoginView)];
        [self.navigationItem setRightBarButtonItem:fbButton];
    

    And then i set the bar button to fire click action of the FBLoginView ;)

    -(void)fireFbLoginView{
    for(id object in self.loginView.subviews){
        if([[object class] isSubclassOfClass:[UIButton class]]){
            UIButton* button = (UIButton*)object;
            [button sendActionsForControlEvents:UIControlEventTouchUpInside];
        }
      }
    }
    

提交回复
热议问题