1

我尝试使用 pixate 在我的应用程序中设置 UISearchBar 文本的样式。它仅在我关闭键盘后才起作用,但是当我编写文本时它不使用我的风格:

我在写:

我在写

键盘关闭后:

键盘关闭后

这是我当前的 CSS:

text-field {
    color: black;
    background-color : @colorEditTexto;
    border-radius: 4px;
    border-width: 8px;
    border-color: gray;
    height: 30px;

    placeholder {
        font-style: italic;
        color: darkgray;
    }
}
search-bar {
    background-color: @colorBarra;
    -ios-tint-color: white;
    color: white;

    text-field {
        color: white;
        placeholder {
            color: white;
        }
    }
}
4

3 回答 3

0

我终于这样做了:

for (UIView* subview in [[self.subviews lastObject] subviews]) {
    if ([subview isKindOfClass:[UITextField class]]) {
        UITextField *textField = (UITextField*)subview;
        textField.styleMode = PXStylingNone;
        [textField setBackgroundColor:[UIColor colorWithHexString:@"#014148"]];
        textField.textColor = [UIColor whiteColor];
    }
}

我有这种风格干扰:

text-field {
    color: black;
    background-color : @colorEditTexto;
    placeholder {
        font-style: italic;
        color: darkgray;
    }
}

这就是为什么有必要设置PXStylingNone.

于 2014-03-03T18:31:35.400 回答
0

尝试添加这样的highlighted伪类:

search-bar {
    background-color: @colorBarra;
    -ios-tint-color: white;
    color: white;

    text-field {
        color: white;
        placeholder {
            color: white;
        }
    }
    text-field:highlighted {
        color: blue;
    }
}
于 2014-01-29T23:07:19.180 回答
0

尝试在搜索栏上设置 styleId 或 styleClass 并直接设置样式,而不是使用元素名称。例如:

#mySearchBar { ... }

此外,Pixate 目前不支持 searchFieldBackgroundImageForState 属性,但我们将很快添加它以更正确地设置搜索栏的背景图像。

最后,设置文本的颜色,现在,这可能是最好的方法,在代码中:

[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
于 2014-01-29T23:36:44.950 回答