ClassyKit / Classy

Expressive, flexible, and powerful stylesheets for UIView and friends.
http://classykit.github.io/Classy/
MIT License
740 stars 77 forks source link

relative dimensions #99

Closed atsepkov closed 6 years ago

atsepkov commented 9 years ago

Coming from css/js world, I keep wishing that we'd have a bit more power in defining dimensions via Classy. I was able to define absolute dimensions via bounds property, which is great. But it doesn't look like relative dimensions are supported. Absolute dimensions, as shown below, are great when I want to restrict the view to exact size:

UITextField {
    /* absolute: */
    bounds: 10, 10, 80, 30
}

More often than not, however, I want to define dimensions relative to the parent container, or passed-in frame:

UITextField2 {
    /* relative */
    bounds: @{
        width: 80%;
    }
}

Currently, I'm very happy with being able to style my views almost completely through cas file, but having to hardcode all the logic for computing child frame, and margins/padding prevents me from relying exclusively on Classy for styling.

keithnorm commented 9 years ago

I come from the web world as well which I why I probably love Classy so much. However, layout with iOS is just fundamentally different and in my opinion layout belongs defined as autolayout constraints in your xib/storyboard, not in your stylesheet. That being said, there is this project https://github.com/olegam/ClassyLiveLayout that you may be interested in.