Search code examples
cssios7pixate

How style the text in a searchbar with pixate?


I have tried to style the UISearchBar text in my app with pixate. It work only after I dismiss the keyboard, but when I'm writing the text it not use my style:

I'm writting:

I'm writting

After the keyboard is closed:

After the keyboard is closed

This is my current 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;
        }
    }
}

Solution

  • I finally do this:

    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];
        }
    }
    

    I have this style interfering:

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

    that is why is necessary to set PXStylingNone.