如何更改Google Plus登录按钮的标题?
我一直在寻找解决方案,但令我惊讶的是,没有人问过这个问题:
如何更改Google登录按钮的标题?
我试图:
- 通过
setTitle:
覆盖标题setTitle:
但没有帮助。 -
在Google Plus框架目录中找到“登录”字符串但是……我的Finder没有找到这样的字符串。 3.使用以下代码更改Facebook登录按钮:
for (id obj in self.signInButtonGPP.subviews) { if ([obj isKindOfClass:[UILabel class]]) { UILabel * label = view; label.text = @"Google"; }}
谢谢
该按钮的资源包含在GooglePlus.bundle文件中。 标签的值来自捆绑包中的GooglePlusPlatform.strings文件。
您可以直接编辑登录键的值以获得自定义标题。 (这可能是一个肮脏的修复,你必须为所有的语言环境做。)
在此过程中,请务必遵守Google+登录按钮品牌指南 。
嗯..我认为你可以使用我改变Facebook登录按钮文本时使用的相同解决方案。 也许它不是最好和最干净的方式,但它确实有效。 您需要做的就是将原始G +登录按钮框架设置为CGRectZero,然后添加与G +按钮具有相同外观的自己的按钮和自定义文本。 比如,当您检测到按钮上的触摸时,您需要将其传递给G +按钮,如下所示:
[self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside];
没有测试它,但我认为它会工作正常。 希望它能帮到你。
我假设您正在使用Google提供的自定义GPPSigninButton
类。
在此示例项目中 ,看起来像“登录”文本是图像的一部分,所以很遗憾,您无法更改此文本。 您必须创建一个按钮并使用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 // 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
不幸的是,这意味着您无法更改此文本。
Google Plus SDK不会为您提供任何设置套装及其SDK。
设置捆绑包含其中使用的所有图像。
Google Plus库具有**。**扩展名表示您无法访问其文件。
此外,登录按钮是一个图像,因此您将无法更改其标题。
尝试子类化GPPSignInButton并根据awakeFromNib方法的需要更改它的图像/标题。
希望这可以帮助..