Open SD10 opened 7 years ago
I thought about this but haven't found a way to set the default values within the protocol without doing it in subclasses. It will be great if we can do it. then we don't need to set a lot of = CGFloat.nan
s
I try something like that using a CSS parser (like 100mango/SwiftCssParser, ...)
but plist or json it's easier
to load file Bundle(forClass: self.dynamicType)
Thank you for sharing SwiftCssParser! I wanted to look at something like this!
I play also with https://github.com/146BC/StyleKit, https://github.com/akane/Gaikan but I want the result in storyboard editor, not at execution time
I try also to edit storyboard XML (by modifying https://github.com/krzyzanowskim/Natalie) to edit some attributes to make a "theme change"
@phimage Yeah, I've looked at StyleKit.
I think having a "theme change" at execution time still provides value. However, like you, I want the result in the storyboard editor. It's not a simple task but I've been playing with it now and then
@phimage If we use a didSet
property observer in the theme
property, won't this parse the stylesheet and apply the values to the storyboard editor?
If you parse your own style sheet(in code or file using the good Bundle to read file) and apply directly to some view attributes, yes it will work on the current view
And if there is issue, you can try with prepareForInterfaceBuilder
IBAnimatable Themes
It would be nice to be able to set default values for IBDesignable classes without having to subclass.
How?
I'm thinking we can add a property:
This would be the name of a
.plist
file to use for the configuration. Then we could parse this file and apply all the values.Some limitations:
UIImage
-- actually, we could just use the IMG name