iOS:使用 Google 按钮登录

标签 ios

我是 iOS 开发的新手,正在从事一个我希望我的用户使用 Google 登录的项目。

我通过 Google 的 documentation 完成了自己的工作,也可以登录。现在我想要的只是按钮/图像,上面写着“使用 Google 登录”作为
enter image description here
我查看了谷歌的 SDK,但没有这样的确切图像。所以我尝试创建自己的看起来像

enter image description here
在 Google 的 SDK 中,ImageView 被替换为图像。

问题
当我运行它时,这看起来不应该

enter image description here

图像和按钮的红色不匹配,我也没有看到垂直黑线。

问题
a.) 在哪里可以找到 iOS 的“使用 Google 登录”按钮?
b.) 下载的 png 可能无法工作,因为根据设备我们需要两种不同的分辨率 @1x@2x

请告诉我怎样才能得到它?

更新
- 问题是 GooglePlus.bundle 没有正确加载到我的项目中。修复后,我看到一个按钮,但没有像

这样的文本

enter image description here

有人见过这个吗?

最佳答案

您不需要看起来像这样的图像,只需使用以下代码代替该按钮,这将创建一个按钮及其操作,为您执行 Google+ SSO。

GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;

//signIn.shouldFetchGoogleUserEmail = YES;  // Uncomment to get the user's email

// You previously set kClientId in the "Initialize the Google+ client" step

signIn.clientID = kClientId;

// Uncomment one of these two statements for the scope you chose in the previous step
signIn.scopes = @[ kGTLAuthScopePlusLogin ];  // "https://www.googleapis.com/auth/plus.login" scope
//signIn.scopes = @[ @"profile" ];            // "profile" scope

// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;

只需将 signIn 按钮添加到您的 View 中,它就会起作用。如果您需要任何帮助,这里是链接

https://developers.google.com/+/mobile/ios/sign-in

关于iOS:使用 Google 按钮登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24490620/

相关文章:

ios - imageview 和 image aspect fit ratio 之间的差异

ios - PFLoginViewController 不使用 Swift 显示 Facebook 登录按钮

ios - 从 UIView 获取 UILabel

ios - 使用cocos2d定位

ios - 在推送和滚动弹出窗口上滚动 UINavigationBar

ios - 自定义测量单位

ios - XCode:仪器有堆栈跟踪吗?

ios - 需要从我的类中的函数返回数组

ios - 无法在 uiview 中动态居中自定义 uibutton

ios - 是否有 iBooks 的 URL 方案?