6

我正在寻找解决方案,但令我惊讶的是,还没有人问过这个问题:

如何更改 Google 登录按钮的标题? 在此处输入图像描述

我试图:

  1. 覆盖标题setTitle:但没有帮助。
  2. 在 Google Plus 框架目录中找到“登录”字符串,但是……我的 Finder 没有找到这样的字符串。3.使用以下代码更改Facebook登录按钮:

    for (id obj in self.signInButtonGPP.subviews)
    {
         if ([obj isKindOfClass:[UILabel class]])
         {  UILabel * label =  view;
            label.text = @"Google";
         }}
    

谢谢

4

4 回答 4

5

按钮的资源包含在GooglePlus.bundle文件中。标签的值来自捆绑包中的GooglePlusPlatform.strings文件。

您可以直接编辑登录键的值以获得自定义标题。(不过,这将是一个肮脏的修复,您必须对所有语言环境都这样做。) 在此处输入图像描述 在此处输入图像描述

在执行此操作时,请务必遵守Google+ 登录按钮品牌指南

于 2015-01-06T15:31:34.247 回答
2

好吧..我认为您可以使用我在更改 Facebook 登录按钮文本时使用的相同解决方案。也许它不是最好和干净的方式,但是..它有效。您需要做的就是将原始 G+ ​​登录按钮框架设置为 CGRectZero,然后添加您自己的与 G+ 按钮外观相同的按钮和自定义文本。比,当您检测到按钮上的触摸时,您需要将其传递给 G+ 按钮,如下所示:

[self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside];

没有测试它,但我认为它会工作得很好。希望它会帮助你。

于 2015-01-06T07:51:36.477 回答
0

Google Plus SDK 不随其 SDK 提供任何设置包。

Settings Bundle 是其中包含所有使用的图像的东西。

Google Plus 库具有**.a** 扩展名意味着您无权访问它的文件。

另外,登录按钮是一个图像,因此您将无法更改其标题。

尝试将GPPSignInButton子类化并根据您的需要在awakeFromNib方法中更改它的图像/标题。

希望这可以帮助..

于 2015-01-06T08:29:12.873 回答
0

我假设您使用的GPPSigninButton是 Google 提供的自定义类。

这个示例项目中,看起来“登录”文本是图像的一部分,因此很遗憾您无法更改此文本。您必须自己创建一个按钮并使用IBAction.

谷歌的示例项目

我使用最新版本的 SDK 创建了自己的示例应用程序。通过View Debugger查看按钮,确实有标签,但是没有暴露在头文件中。

//
//  GPPSignInButton.h
//  Google+ iOS SDK
//
//  Copyright 2012 Google Inc.
//
//  Use of this SDK is subject to the Google+ Platform Terms of Service:
//  https://developers.google.com/+/terms
//

#import <UIKit/UIKit.h>

// The various layout styles supported by the GPPSignInButton.
// The minmum size of the button depends on the language used for text.
// The following dimensions (in points) fit for all languages:
// kGPPSignInButtonStyleStandard: 226 x 48
// kGPPSignInButtonStyleWide:     308 x 48
// kGPPSignInButtonStyleIconOnly:  46 x 48 (no text, fixed size)
typedef enum {
  kGPPSignInButtonStyleStandard = 0,
  kGPPSignInButtonStyleWide = 1,
  kGPPSignInButtonStyleIconOnly = 2
} GPPSignInButtonStyle;

// The various color schemes supported by the GPPSignInButton.
typedef enum {
  kGPPSignInButtonColorSchemeDark = 0,
  kGPPSignInButtonColorSchemeLight = 1
} GPPSignInButtonColorScheme;

// This class provides the Google+ sign-in button. You can instantiate this
// class programmatically or from a NIB file.  You should set up the
// |GPPSignIn| shared instance with your client ID and any additional scopes,
// implement the delegate methods for |GPPSignIn|, and add this button to your
// view hierarchy.
@interface GPPSignInButton : UIButton

// The layout style for the sign-in button. The default style is standard.
@property(nonatomic, assign) GPPSignInButtonStyle style;

// The color scheme for the sign-in. The default scheme is dark.
@property(nonatomic, assign) GPPSignInButtonColorScheme colorScheme;

@end

我自己的示例项目

不幸的是,这意味着您无法更改此文本。

于 2015-01-05T21:27:05.177 回答