2013-10-19 2 views
20

新しいiOS7 UIView色合いを使用すると、アプリケーション全体をすばやくテーマにすることがかなり簡単になります。 UITextFieldを編集するときにテキストキャレットの色を変更することさえできます。iOS7キーボードReturn/Done /色合いの色を検索

しかし、キーボードの右下の「破棄」ボタン(完了、検索など)は常に青です。これを変更する方法はありますか?アプリの残りの部分の色合いに合っていれば本当にいいと思うだろう。

iOS7 UISearchBar keyboard

答えて

29

おそらく、あなたが探している効果を達成することができます。しかし、アプリレビューに合格できない可能性があります。

-(NSArray*)subviewsOfView:(UIView*)view withType:(NSString*)type{ 
    NSString *prefix = [NSString stringWithFormat:@"<%@",type]; 
    NSMutableArray *subviewArray = [NSMutableArray array]; 
    for (UIView *subview in view.subviews) { 
     NSArray *tempArray = [self subviewsOfView:subview withType:type]; 
     for (UIView *view in tempArray) { 
      [subviewArray addObject:view]; 
     } 
    } 
    if ([[view description]hasPrefix:prefix]) { 
     [subviewArray addObject:view]; 
    } 
    return [NSArray arrayWithArray:subviewArray]; 
} 

-(void)addColorToUIKeyboardButton{ 
    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) { 
     for (UIView *keyboard in [keyboardWindow subviews]) { 
      for (UIView *view in [self subviewsOfView:keyboard withType:@"UIKBKeyplaneView"]) { 
       UIView *newView = [[UIView alloc] initWithFrame:[(UIView *)[[self subviewsOfView:keyboard withType:@"UIKBKeyView"] lastObject] frame]]; 
       newView.frame = CGRectMake(newView.frame.origin.x + 2, newView.frame.origin.y + 1, newView.frame.size.width - 4, newView.frame.size.height -3); 
       [newView setBackgroundColor:[UIColor greenColor]]; 
       newView.layer.cornerRadius = 4; 
       [view insertSubview:newView belowSubview:((UIView *)[[self subviewsOfView:keyboard withType:@"UIKBKeyView"] lastObject])]; 

      } 
     } 
    } 
} 

私はビュー階層を復号化するために使用されるアプリはでした:Green Key

+1

ハ、私はこの質問をした直後にRevealをダウンロードしてテストしました。誰でも公開アプリでこれを試しましたか?レビュープロセスに関するフィードバックはありますか? – Tyson

+1

私はおそらくレビューに失敗すると思います。この質問はこちら[http://stackoverflow.com/questions/4202817/can-i-tint-black-a-uikeyboard-if-so-how](http://stackoverflow.com/questions/4202817/can -i-tint-black-a-uikeyboard-if-so-how)また、キーボードの後ろに色付けされたビューを置いて、一般的に色付けすることもできます。 –

+0

また、あなたが私の答えを投票できるなら、本当にうれしいでしょう。私はまったく新しいと私は実際に私は直接画像を投稿するなど、投票などから私を防ぐ担当者の低実行しています。ありがとう –

4

あなたはボタンの色合いの色を変更することはできませんが、例UIKeyboardAppearance

image

を使用してkeyboard色合いの色を設定することができます。ここではyourTextField.keyboardAppearance = UIKeyboardAppearanceDark;

は非常にいい文書でありますアップルが提供する、ここをクリックしてください:

Managing the Keyboard

+0

おかげで、私はすでにの認識しています:http://revealapp.com/

最終結果はこのようなものです暗い/明るいキーボード私の質問は、具体的にはキーボードの「却下」ボタンに関するものでした。それはリンゴのデフォルトのiOS7色合いの色にマッチしているようですので、変更することもできたと思っていました。 – Tyson

+0

あなたは確かにキーボードウィンドウの色合いを変更することができます。それは文書化されておらず、ビューの階層でそれを見つけなければなりません。それは私が言うと思う非常に軽量のパッチです。 – Andy

0
let colors: [UIColor] = [.red, .blue, .green, .purple, .yellow, .orange, .brown] 

if let window = UIApplication.shared.windows.first(where: { 
    $0.isType(string: "UIRemoteKeyboardWindow") 
}) { 
    if let keyplaneView = window.subview(ofType: "UIKBKeyplaneView") { 
     for (i, keyView) in keyplaneView.subviews.filter({ 
      $0.isType(string: "UIKBKeyView") 
     }).enumerated() { 
      let view = UIView(frame: keyView.bounds) 
      view.backgroundColor = colors[i].withAlphaComponent(0.5) 
      keyView.addSubview(view) 
     } 
    } 
} 

Here is a color map of the keys in the UIKBKeyplaneView