如何自定义谷歌登录按钮?

Bur*_*lar 1 ios google-signin gidsignin

1)当我创建一个UIView具有大小(x,y)并且其类型的大小时GIDSignInButton,它会在大小(z,t)中显示一个Google登录按钮,其中z < xt < y.为什么?如何让它显示尺寸为(x,y)的Google登录按钮?

2)我添加了带有CocoaPods的Google Sign In SDK.如何在Google登录按钮中设置文本的对齐方式?如何设置字体大小?

我添加了Google登录按钮,如Google的文档中所述.

Man*_*ani 5

自定义GIDSignInButton

对于你们两个问题:

Google不允许我们以GIDSignInButton各种方式自定义.但是我们可以改变一些可用的属性.

下面提到了这些属性,并解释了如何设置它们.我们将在名为的插座按钮上设置这些属性signInButton.

  1. GIDSignInButtonStyle :登录按钮的布局样式.

    [self.signInButton setStyle:kGIDSignInButtonStyleIconOnly];
    
    Run Code Online (Sandbox Code Playgroud)

    style物业有三个可能的价值.

    • kGIDSignInButtonStyleStandard :: 230 x 48(默认)
    • kGIDSignInButtonStyleWide :312 x 48
    • kGIDSignInButtonStyleIconOnly :48 x 48(无文字,固定尺寸)
  2. GIDSignInButtonColorScheme :登录按钮的颜色方案.

    [self.signInButton setColorScheme:kGIDSignInButtonColorSchemeDark];
    
    Run Code Online (Sandbox Code Playgroud)

    colourScheme物业有两个可能的价值.

    • kGIDSignInButtonColorSchemeDark
    • kGIDSignInButtonStyleWide :(默认)
  3. IBOutlet UIViewController * :代表

    DelegateViewController *uiVC = [[DelegateViewController alloc] init];
    [self.signInButton setDelegate:uiVC];
    
    Run Code Online (Sandbox Code Playgroud)

如果您希望Google登录按钮仅作为徽标,则必须将视图大小设置为大于48X48,这是徽标的默认大小.

如需进一步参考,您可以访问适用于iOS的Google Sign-In