iOS7 键盘返回/完成/搜索色调颜色

2024-02-19

借助新的 iOS 7 UIView 色调颜色,可以轻松快速地为整个应用程序设置主题。它甚至在编辑文本字段时更改文本插入符号的颜色。

但是,键盘右下角的“关闭”按钮(可以是“完成”、“搜索”等)始终为蓝色。有什么办法可以改变这个吗?如果它与应用程序其余部分的色调颜色相匹配,它看起来会非常漂亮。


通过一点技巧,也许您可​​以实现您正在寻找的效果。但它可能无法通过应用程序审核。

-(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/ http://revealapp.com/

The end result is like this: Green Key

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iOS7 键盘返回/完成/搜索色调颜色 的相关文章

随机推荐