iOS7键盘返回/完成/搜索色调颜色 [英] iOS7 Keyboard Return/Done/Search tint colour

查看:117
本文介绍了iOS7键盘返回/完成/搜索色调颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用新的iOS7 UIView色调,可以快速主题化整个应用程序。它甚至在编辑UITextFields时会改变文本插入符号的颜色。

With the new iOS7 UIView tint color it becomes pretty easy to theme an entire app quickly. It even changes the color of the text caret when editing UITextFields.

然而,键盘的右下角关闭按钮(可以是完成,搜索等)总是蓝色。有没有办法改变这个?如果它与应用程序其余部分的色调相匹配,那将会非常好看。

However, the keyboard's bottom right 'dismiss' button (can be Done, Search, etc) is always blue. Is there any way to change this? It would look really nice if it matched the tint color of the rest of the app.

推荐答案

有了一点点黑客,也许你可以达到你想要的效果对于。但它可能无法通过应用审核。

With a little hack maybe you can achieve the effect you are looking for. But it might not be able to pass the app review.

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

            }
        }
    }
}

我用来解码视图层次结构的应用程序是: http://revealapp.com/

The app I used to decode the view hierarchy was : http://revealapp.com/

最终结果如下:

这篇关于iOS7键盘返回/完成/搜索色调颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆