如何自定义Google登录按钮? [英] How to customize google sign in button?

查看:379
本文介绍了如何自定义Google登录按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

1) When I created a UIView which has size (x, y), and made its type GIDSignInButton, it shows up a Google Sign In button in the size (z, t) where z < x and t < y. Why? How can I make it show a Google Sign In button with size (x, y)?

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

2) I added Google Sign In SDK with CocoaPods. How can I set the alignment of the text in the Google Sign In button? How can I set the font size?

我按照Google文档中的说明添加了Google登录按钮.

I added Google Sign In button as described in the Google's doc.

推荐答案

自定义GIDSignInButton

您的两个问题:

Google不允许我们以各种方式自定义GIDSignInButton.但是,有些属性可以更改.

Google doesn't allow us to customise the GIDSignInButton in every way. But There are some properties available that we can change.

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

The properties are mentioned below and explained how to set them. We will set these properties on the outlet button named signInButton.

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

  1. GIDSignInButtonStyle : The layout style for the sign-in button.

[self.signInButton setStyle:kGIDSignInButtonStyleIconOnly];

style属性具有三个可能的值.

The style property has three possible values.

  • kGIDSignInButtonStyleStandard::230 x 48(默认)
  • kGIDSignInButtonStyleWide:312 x 48
  • kGIDSignInButtonStyleIconOnly:48 x 48(无文本,固定大小)
  • kGIDSignInButtonStyleStandard : : 230 x 48 (default)
  • kGIDSignInButtonStyleWide : 312 x 48
  • kGIDSignInButtonStyleIconOnly : 48 x 48 (no text, fixed size)

GIDSignInButtonColorScheme:登录按钮的配色方案.

GIDSignInButtonColorScheme : The color scheme for the sign-in button.

[self.signInButton setColorScheme:kGIDSignInButtonColorSchemeDark];

colourScheme属性具有两个可能的值.

The colourScheme property has two possible values.

  • kGIDSignInButtonColorSchemeDark
  • kGIDSignInButtonStyleWide :(默认)
  • kGIDSignInButtonColorSchemeDark
  • kGIDSignInButtonStyleWide : (Default)

IBOutlet UIViewController *:委派

DelegateViewController *uiVC = [[DelegateViewController alloc] init];
[self.signInButton setDelegate:uiVC];

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

If you want google sign in button as just logo, you will have to set the view size bigger then 48X48, which is default size for the logo.

有关更多参考,您可以访问 iOS的Google登录

For further references you can visit Google Sign-In for iOS

这篇关于如何自定义Google登录按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆