Ios 如何更改Google Plus登录按钮的标题?

Ios 如何更改Google Plus登录按钮的标题?,ios,objective-c,google-plus,google-plus-signin,Ios,Objective C,Google Plus,Google Plus Signin,我一直在寻找解决办法,但令我惊讶的是,还没有人问这个问题: 如何更改谷歌登录按钮的标题? 我试图: 通过setTitle:覆盖标题,但没有帮助 在GooglePlus框架目录中找到“登录”字符串,但是。。。我的发现者没有找到这样的字符串。 3.使用以下代码更改Facebook登录按钮: for (id obj in self.signInButtonGPP.subviews) { if ([obj isKindOfClass:[UILabel class]]) { UIL

我一直在寻找解决办法,但令我惊讶的是,还没有人问这个问题:

如何更改谷歌登录按钮的标题?

我试图:

  • 通过
    setTitle:
    覆盖标题,但没有帮助
  • 在GooglePlus框架目录中找到“登录”字符串,但是。。。我的发现者没有找到这样的字符串。 3.使用以下代码更改Facebook登录按钮:

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

  • 谢谢

    我假设您使用的是谷歌提供的自定义
    GPPSigninButton

    在中,“登录”文本似乎是图像的一部分,因此很遗憾,您无法更改此文本。您必须创建一个按钮,并使用
    iAction
    自行处理登录事件

    我已经使用最新版本的SDK创建了自己的示例应用程序。通过查看调试器查看按钮,它确实有一个标签,但它没有显示在头文件中

    //
    //  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
    
    //
    //GPPSignInButton.h
    //Google+iOS SDK
    //
    //版权所有2012谷歌公司。
    //
    //此SDK的使用受Google+平台服务条款的约束:
    //  https://developers.google.com/+/条件
    //
    #进口
    //GPPSignInButton支持的各种布局样式。
    //按钮的最小大小取决于用于文本的语言。
    //以下尺寸(以点为单位)适用于所有语言:
    //KGP点火按钮样式标准:226 x 48
    //KGP点火按钮样式宽:308 x 48
    //kgppsigninButtonStyleIconly:46 x 48(无文本,固定大小)
    类型定义枚举{
    KgpSignInButtonStyleStandard=0,
    KgpSignInButtonStyleWide=1,
    KgpSignInButtonStyleIcononly=2
    }GPPSignInButtonStyle;
    //GPPSignInButton支持的各种颜色方案。
    类型定义枚举{
    KgpSignInButtonColorschemeDARK=0,
    kgppsigninbuttoncolorschemlight=1
    }gppsigninbuttoncolor方案;
    //此类提供Google+登录按钮。您可以实例化这个
    //以编程方式或从NIB文件初始化。你应该设置
    //| GPPSignIn |与您的客户端ID和任何其他作用域共享实例,
    //实现| GPPSignIn |的委托方法,并将此按钮添加到
    //视图层次结构。
    @接口GPPSignInButton:UIButton
    //登录按钮的布局样式。默认样式为标准样式。
    @属性(非原子,赋值)GPPSignInButtonStyle样式;
    //登录的颜色方案。默认方案是暗的。
    @属性(非原子,赋值)GPPSignInButtonColorScheme颜色方案;
    @结束
    

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

    嗯。。 我想你们可以使用我在更改Facebook登录按钮文本时使用的相同解决方案。也许这不是最好的清洁方式,但是。。它起作用了。 您所需要做的就是将原来的G+登录按钮框架设置为CGRectZero,然后添加与G+按钮外观相同的按钮和自定义文本。然后,当您检测到触摸按钮时,需要将其传递给G+按钮,如下所示:

    [self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside];
    
    我没有测试,但我认为它可以正常工作。
    希望它能帮助您。

    Google Plus SDK没有随SDK提供任何设置包

    设置包中包含所有使用的图像

    Google Plus库有**。一个**扩展名意味着你不能访问它的文件

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

    尝试子类化GPPSignInButton,并根据需要在awakeFromNib方法中更改其图像/标题


    希望这有帮助。

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

    您可以直接编辑登录键的值,以获得自定义标题。(但这将是一个肮脏的修复,您必须对所有区域设置执行此操作。)


    在执行此操作时,请确保遵守。

    您的意思是:UILabel*label=obj;正确的?