How do I change the name of the Google Plus login button?

I was looking for a solution, but to my surprise, no one has asked this question yet:

How do I change the name of the Google login button? enter image description here

I have tried:

  • override the setTitle: header, but that didn't help.
  • find the "Login" line in the Google Plus infrastructure directory, but ... my Finder did not find such a line. 3. Use the following code that works to change the Facebook login button:

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

thanks

+5
source share
4 answers

The resources for the button are contained in the GooglePlus.bundle file. The value for the label comes from the bundled GooglePlusPlatform.strings file.

You can directly change the value of the Login key to have your own title. (This would be a dirty solution, but you have to do this for all locales.) enter image description hereenter image description here

And be sure to follow the Google+ Button Branding Guide .

+4
source

Well .. I think you can use the same solution that I used when I had to change the text of the Facebook login button. Maybe this is not the best and clean way, but .. it works. All you have to do is set the initial frame of the G + login button to CGRectZero, and then add your own button with the same appearance as the G + button, and custom text. Then, when you find a touch on your button, you need to transfer it to the G + button as follows:

 [self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside]; 

Not tested, but I think that everything will be fine. Hope this helps you.

+2
source

I assume that you are using the custom GPPSigninButton class that Google provides.

In this sample project , it looks like the text β€œInput” is part of the image, so unfortunately you cannot change this text. You will need to create a button and handle the login event yourself using IBAction .

Google's Sample Project

I created my own sample application using the latest version of the SDK. Looking at the button through the View Debugger, it has a label, but it does not appear in the header file.

 // // 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 

My own sample project

Unfortunately, this means that you cannot change this text.

0
source

The Google Plus SDK does not provide you with a set of settings along with the SDK.

Bundle settings - this is what contains all the images used inside it.

The Google Plus Library has **. ** extension means that you do not have access to it.

In addition, the login button is an image, so you cannot change the title.

Try to subclass GPPSignInButton and change its image / title to suit your needs in the awakeFromNib method.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1210410/


All Articles