Skip to content
This repository was archived by the owner on Jun 19, 2019. It is now read-only.
This repository was archived by the owner on Jun 19, 2019. It is now read-only.

support for UISearchBar #98

@atsepkov

Description

@atsepkov

Thanks for the project guys. I really appreciate that Classy made it easy for me to style/simplify the UI of my app without spending days doing so in the code. One thing that still refuses to be styled, however, is UISearchBar. Having researched this element and its structure, I'm now convinced that it's the worst-designed element in all of UIKit.

The problem is that it stacks several UIView layers within itself, hardcoding a style that only fits basic UI, using background images to fake borders instead of the readily-available and consistent borderWidth/borderColor/cornerRadius properties, hardcodes an unnecessary top and bottom border that can't be removed (but can be hidden via secondary border) and doesn't properly expose any of its underlying hackery to the developer using or inheriting from this class. Luckily, I found a combination of hackery that counters the damage (I know, not the cleanest approach) and creates a simple and clean search box that I would expect:

searchBar.layer.borderColor = UIColor.whiteColor().CGColor // to remove the hardcoded top/bottom borders
searchBar.layer.borderWidth = 1 // same as above
searchBar.barTintColor = UIColor.whiteColor() // conceal ugly background image into the same color as hardcoded into the search window itself (white)

Problem is when I move this to the stylesheet as follows, it seems to have no effect:

UISearchBar {
    bar-tint-color: #ffffff;
    layer: @{
        border-width: 1;
        border-color: #ffffff;
    }
}

But when I replace UISearchBar with ^UIView, the properties set in layer are applied (but not the barTintColor, which is a UISearchBar-only property). I've been struggling with this for a few hours now and have come to a conclusion that UISearchBar is simply ignored by Classy. Is this a bug, a limitation, something else?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions