2015-01-05 9 views
5

私は解決策を探していましたが、驚いたことに誰もこの質問をまだ聞いていませんでした。Google Plusログインボタンのタイトルを変更するにはどうすればよいですか?

Googleログインボタンのタイトルを変更するにはどうすればよいですか? setTitle:によって

  1. オーバーライドタイトルが、助けにはならなかった。 enter image description here

    私がしようとしていました。

  2. Google Plusのフレームワークディレクトリに「ログイン」文字列が見つかりましたが、よくわかりました。Finderでこのような文字列が見つかりませんでした。 Facebookログインボタンを変更するための作品次のコード3.Use :

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

は、私はあなたがGoogleが提供するカスタムGPPSigninButtonクラスを使用していると仮定しているあなたに

+0

あなたはUILabel * label = obj;右? – jerrygdm

答えて

4

は、ボタンのリソースは、GooglePlus.bundleファイルに含まれています。ラベルの値は、バンドル内のGooglePlusPlatform.stringsファイルから取得されています。

の値を直接編集してにサインインすると、カスタムタイトルを持つことができます。 (これはしかし汚い修正になり、あなたはすべてのロケールのためにそれを行う必要があります。) enter image description here enter image description here

そして、それはGoogle+ Sign-In button branding guidelinesに準拠するようにしてください行っている間。

+0

それは動作します!ありがとう@アルプス! –

+0

すごいいい答え、ありがとう。 – JAL

0

ありがとうございます。 this sample project

は、のように見えるテキストが画像の一部である「サインイン」、そう残念ながらあなたはこのテキストを変更することはできません。 IBActionでボタンを作成し、サインインイベントを自分で処理する必要があります。

Google's Sample Project

私は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 

My Own Sample Project

残念ながら、これはあなたがこのテキストを変更することはできませんを意味します。

+0

never never say –

2

まあ、 Facebookのログインボタンのテキストを変更するときに使用したのと同じソリューションを使用できると思います。多分それは最高でない&クリーンな方法ですが、それは動作します。 オリジナルのG +ログインボタンフレームをCGRectZeroに設定し、G +ボタンと同じ外観の独自のボタンとカスタムテキストを追加するだけです。あなたはボタンのタッチを検出したときに、このようなG +ボタンにそれを渡す必要があり、より:

[self.gppSigninButton sendActionsForControlEvents:UIControlEventTouchUpInside]; 

はそれをテストしていないが、私はそれが正常に動作と思います。 お手伝いしますように。

0

Google Plus SDKは、SDKとともに設定バンドルを提供していません。

設定バンドルは、その内部で使用されるすべてのイメージを持つものです。

Google Plusライブラリには** .a **という拡張子があります。この拡張子は、ファイルにアクセスできないことを意味します。

さらに、サインインボタンは画像であるため、タイトルを変更することはできません。

GPPSignInButtonのサブクラスを試してみて、 awakeFromNib方法であなたの必要性に従って、それだ画像/タイトルを変更。このことができます

・ホープ..

関連する問題