2015-02-11 238 views
0

我在我的应用中包含FB和G + SignUp。如何自定义Google+登录按钮

唯一我找不到答案的是如何自定义GPPSignInButton

我做了一个普通的UIButton,并将其类改为GPPSignInButton。

结果是这样的:

enter image description here

我不知道这是什么蓝色区域是我们的,怎么会出现在那里,但我不能调用任何这些方法改变它

_gButton.backgroundColor = [UIColor redColor]; 
[_gButton setBackgroundColor:[UIColor redColor]]; 
[_gButton setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal]; 

我只需要一个谷歌登录按钮是透明的按钮。 如何实现这一目标?

回答

2

你可以有你自己的UIButton,它与IBAction连接到您的UIViewController和运行认证过程自己之后,这就是登录按钮呢幕后:

- (IBAction)signInWithGooglePlusButtonPressed:(UIButton *)sender { 
    GPPSignIn *googleSignIn = [GPPSignIn sharedInstance]; 
    googleSignIn.shouldFetchGooglePlusUser = YES; 
    googleSignIn.shouldFetchGoogleUserEmail = YES; 
    googleSignIn.clientID = @"CLIENT_ID"; 
    googleSignIn.scopes = @[ @"profile" ]; 
    googleSignIn.delegate = self; 

    [googleSignIn authenticate]; 
} 
+0

该死的。 这就是我正在做的,我想知道为什么我不成功... 现在我看到,我忘了最后一种方法:) 感谢Gorka! – SteBra 2015-02-12 09:16:34

+0

不客气,@SteBra;) – Gorka 2015-02-12 14:15:10

+0

@Gorka真的很棒。它似乎正在工作新的api.Thanks人 – 2015-09-21 13:05:33

1

我有类似的问题,我用这种方式解决了这个问题:我创建了gppSignInButton,但没有将它添加为子视图,然后创建了我自己的按钮,使其视图完全像我需要的,然后将操作loginViaGP添加到我自己的按钮

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    _gppSignInButton = [[GPPSignInButton alloc] init]; 
} 

- (IBAction)loginViaGP:(id)sender 
{ 
    [_gppSignInButton sendActionsForControlEvents:UIControlEventTouchUpInside]; 
} 

所以单击我的按钮G +对话框被称为

0

我在viewDidLoad中做了以下工作,它的工作方式就像一个魅力。

[self.googlePlusBtn setImage:nil forState:UIControlStateNormal]; 
[self.googlePlusBtn setImage:nil forState:UIControlStateHighlighted]; 
[self.googlePlusBtn setImage:nil forState:UIControlStateSelected];