iOS7 Keyboard Return / Done/Search tint colour

Z nowym iOS7 UIView tint color staje się dość łatwe do tematu całej aplikacji szybko. Zmienia nawet kolor karetki tekstowej podczas edycji UITextFields.

Jednak prawy dolny przycisk "Odrzuć" na klawiaturze (można to zrobić, wyszukać itp.) jest zawsze niebieski. Czy można to jakoś zmienić? Wyglądałoby to naprawdę ładnie, gdyby pasowało do koloru odcienia reszty aplikacji.

klawiatura iOS7 UISearchBar

Author: Brad Larson, 2013-10-19

3 answers

Z odrobiną hack może uda Ci się osiągnąć efekt, którego szukasz. Ale może nie być w stanie przejść przeglądu aplikacji.

-(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])];

            }
        }
    }
}

Aplikacja, której użyłem do dekodowania hierarchii widoków to: http://revealapp.com/

Efekt końcowy wygląda następująco: Zielony Klucz

 32
Author: Ömer Karışman,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-21 10:32:47

Nie można zmienić koloru przycisku, ale można ustawić keyboard Kolor Tint za pomocą UIKeyboardAppearance

obraz

Przykład: yourTextField.keyboardAppearance = UIKeyboardAppearanceDark;

Oto bardzo ładny dokument dostarczony przez Apple, spójrz tutaj:

Zarządzanie klawiaturą

 4
Author: Nitin Gohel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-25 04:11:58
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)
        }
    }
}

Oto kolorowa Mapa klawiszy w UIKBKeyplaneView

 0
Author: Callam,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-29 00:47:11