Closed jsslai closed 9 years ago
@jsslai I'm hoping to really improve the Motif Swift API in 0.3
, but in the interim you should be able to use something along the lines of:
let objCType = NSValue(UIEdgeInsets: UIEdgeInsetsZero).objCType
self.mtf_registerThemeProperty("someEdgeInsets", requiringValueOfObjCType: objCType) { (value, view) -> Void in
// Apply your value
}
Let me know if this doesn't work, thanks!
Thanks, it worked. I also had to change the theme.json property style for edge insets from "{0, 0, 0, 0}" to [0, 0, 0, 0]. I thought the JSON syntax was still the same...
@jsslai The JSON syntax is roughly the same—the string transformers for C structs were just deprecated in place of dictionary, array, and number transformers. So now, you can declare your edge insets as:
"insets": [1, 2, 3, 4]
"insets": {"left" = 10, "right" = 20}
or
"insets": 10
Which will give you an edge insets with all elements set to 10. Hopefully that's an improvement over the old string way of doing things!
Did you also change the order of insets? Now [1, 2, 3, 4] gives:
(UIEdgeInsets) $R1 = (top = 1, left = 4, bottom = 3, right = 2)
@jsslai Yes—it now follows a similar pattern to that of CSS padding/margins. See https://developer.mozilla.org/en-US/docs/Web/CSS/padding#Formal_syntax
How do I add property applier for UIEdgeInsets in Swift? If I understood correctly, Objective-C version of property applier for UIEdgeInsets would be something like this:
But Swift doesn't have @encode compiler directive.