IOS 改变键盘颜色的代码

红米和iPod
touch的键盘颜色其实是得透过代码更改的,这样可以还匹配App的界面风格,下面是反小米键盘颜色的代码。
1、唯有Number Pad和Phone Pad这半种植平板键盘才生效率2、设置Appearance为Alert

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    NSArray *ws = [[UIApplication sharedApplication] windows];
    for(UIView *w in ws){
        NSArray *vs = [w subviews];
        for(UIView *v in vs){
            if([[NSString stringWithUTF8String:object_getClassName(v)] isEqualToString:@"UIPeripheralHostView"]){
                v.backgroundColor = [UIColor redColor];
            }
        }
    }
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    NSArray *ws = [[UIApplication sharedApplication] windows];
    for(UIView *w in ws){
        NSArray *vs = [w subviews];
        for(UIView *v in vs){
            if([[NSString stringWithUTF8String:object_getClassName(v)] isEqualToString:@"UIPeripheralHostView"]){
                v.backgroundColor = [UIColor redColor];
            }
        }
    }
}
//该片段来自于http://outofmemory.cn

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图