Closed radimhalfar closed 6 years ago
in fact not. because if you set the color in IB and apply no color in style - the style due to defaults automatically sets .backgroundColor(nil), thus it overwrites the value set in IB
I looked into it and after further inspection I'm still conviced that this is not a bug. Let me explain: One of the problems that Styles are trying to address is scattered styling. Often times we can see projects where various style properties for single view (or control) are defined in multiple places. Xibs, Storyboards or directly in code. This makes it inherently hard to change and keep track of global styling. Imagine switching theme in project where you have to dig inside every view subclass and (or) it's xib, every storyboard and (or) every controller only to able to recognize styling entry points. With Styles, we are making styling obvious and developers can rely on the fact that everything regarding the styling of that particular view is defined in it's ViewStyle and vice versa, what is not defined in it, does not count. I agree that it seems bit odd to cancel whatever is not defined in the ViewStyle, but this behaviour makes it really easy to reason about styling.
Ok then, I agree. However to make it more obvious I would suggest to change ViewStyle.Property to struct providing init with pre-defined properties which may be overwritten by developer using it.
i.e -
ViewStyle.default
init(backgroundColor: UIColor?, tintColor: UIColor, opacity: Float, corners: ...)
}
What do you think ? 🙂
that is intended behavior