Skip to content

Variation on IBEnum? #594

@phimage

Description

@phimage

Just want to discuss about a potential feature.

Unfortunately I think we cannot do "Trait Variation" for "User Defined Runtime Attributes"
So when we define something, it is for all ipads and iphones

I make a little PoC using NSDataAsset, that can be variated

A data asset named mask
screenshot 2018-10-04 at 11 05 14

Inside I put just some text file with the wanted value of a maskType

  • iphone file contains: circle
  • ipad file contains: ellipse

Then in MaskType I add a code to parse NSDataAsset

public extension MaskType {
  init(string: String?) {
....
case "dataAsset":
      if let name = params[safe: 0],
        let dataAsset = NSDataAsset(name: name),
        let value = String(data: dataAsset.data, encoding: .utf8) {
        self.init(string: value)
      } else {
        self = .none
      }

And finally I use it on my view in storyboard like this
dataAsset(mask)

on iphone a circle
screenshot 2018-10-04 at 11 11 41

on ipad an ellipse
screenshot 2018-10-04 at 10 54 20

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