如何更改 Google Plus 登录按钮的标题?
How to change title of Google Plus Sign in button?
我正在寻找解决方案,但令我惊讶的是还没有人问这个问题:
如何更改 Google 登录按钮的标题?
我正在尝试:
- 通过
setTitle:
覆盖标题但没有帮助。
在 Google Plus 框架目录中找到 "Sign in" 字符串,但是...我的 Finder 没有找到这样的字符串。
3.Use 以下代码可用于更改 Facebook 登录按钮:
for (id obj in self.signInButtonGPP.subviews)
{
if ([obj isKindOfClass:[UILabel class]])
{ UILabel * label = view;
label.text = @"Google";
}}
谢谢
我假设您正在使用 Google 提供的自定义 GPPSigninButton
class。
在 this sample project 中,看起来 "Sign In" 文本是图像的一部分,因此很遗憾,您无法更改此文本。您将必须创建一个按钮并使用 IBAction
.
自己处理 sign-in 事件
我已经使用最新版本的 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
很遗憾,这意味着您无法更改此文本。
嗯..
我认为您可以使用我在更改 Facebook 登录按钮文本时使用的相同解决方案。也许这不是最好和最干净的方法,但是..它有效。
您需要做的就是将您的原始 G+ 登录按钮框架设置为 CGRectZero,然后添加您自己的具有与 G+ 按钮相同外观的按钮和自定义文本。然后,当您检测到触摸按钮时,您需要像这样将其传递给 G+ 按钮:
[self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside];
没有测试,但我认为它会工作正常。
希望对你有帮助。
Google Plus SDK 不提供任何设置包及其 SDK。
Settings Bundle 是其中包含所有图像的东西。
Google Plus 库有**.a** 扩展名意味着您无权访问它的文件。
另外,“登录”按钮是一张图片,因此您无法更改它的标题。
尝试子类化 GPPSignInButton 并根据需要在 awakeFromNib 方法中更改其图像/标题。
希望这对您有所帮助..
按钮的资源包含在 GooglePlus.bundle 文件中。标签的值来自包中的 GooglePlusPlatform.strings 文件。
您可以直接编辑 登录 键的值以获得自定义标题。 (尽管这将是一个肮脏的修复,您必须对所有语言环境都这样做。)
我正在寻找解决方案,但令我惊讶的是还没有人问这个问题:
如何更改 Google 登录按钮的标题?
我正在尝试:
- 通过
setTitle:
覆盖标题但没有帮助。 在 Google Plus 框架目录中找到 "Sign in" 字符串,但是...我的 Finder 没有找到这样的字符串。 3.Use 以下代码可用于更改 Facebook 登录按钮:
for (id obj in self.signInButtonGPP.subviews) { if ([obj isKindOfClass:[UILabel class]]) { UILabel * label = view; label.text = @"Google"; }}
谢谢
我假设您正在使用 Google 提供的自定义 GPPSigninButton
class。
在 this sample project 中,看起来 "Sign In" 文本是图像的一部分,因此很遗憾,您无法更改此文本。您将必须创建一个按钮并使用 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
很遗憾,这意味着您无法更改此文本。
嗯.. 我认为您可以使用我在更改 Facebook 登录按钮文本时使用的相同解决方案。也许这不是最好和最干净的方法,但是..它有效。 您需要做的就是将您的原始 G+ 登录按钮框架设置为 CGRectZero,然后添加您自己的具有与 G+ 按钮相同外观的按钮和自定义文本。然后,当您检测到触摸按钮时,您需要像这样将其传递给 G+ 按钮:
[self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside];
没有测试,但我认为它会工作正常。 希望对你有帮助。
Google Plus SDK 不提供任何设置包及其 SDK。
Settings Bundle 是其中包含所有图像的东西。
Google Plus 库有**.a** 扩展名意味着您无权访问它的文件。
另外,“登录”按钮是一张图片,因此您无法更改它的标题。
尝试子类化 GPPSignInButton 并根据需要在 awakeFromNib 方法中更改其图像/标题。
希望这对您有所帮助..
按钮的资源包含在 GooglePlus.bundle 文件中。标签的值来自包中的 GooglePlusPlatform.strings 文件。
您可以直接编辑 登录 键的值以获得自定义标题。 (尽管这将是一个肮脏的修复,您必须对所有语言环境都这样做。)