Giter Club home page Giter Club logo

Comments (12)

cloudkite avatar cloudkite commented on July 22, 2024

If you are doing your layout in custom UIView subclasses then you can already take advantage of live reload by using Classy to set the constants of your constraints. You would need to turn your constants into properties on your view class.

custom UIView subclass:

@interface MYCustomView : UIView

@property (nonatomic, assign) UIOffset someOffset

@end
@implementation MYCustomView

- (void)setSomeOffset:(UIOffset)someOffset {
   _someOffset = someOffset
   [self setNeedsUpdateConstraints];
}

- (void)updateConstraints {
   [super updateConstraints];

   [self.someView mas_updateConstraints:^(MASConstraintMaker *make) {
      make.top.equalTo(self).with.offset(self.someOffset.vertical);
      make.left.equalTo(self).with.offset(self.someOffset.horizontal);
  }];
}

@end

in classy stylesheet

MYCustomView {
  someOffset 10, 5
}

Let me know how you get on 👍

from masonry.

olegam avatar olegam commented on July 22, 2024

Thats a great idea! Would be nice to be able to use it everywhere (also when not doing subclasses) and without the boilerplate. Maybe I can do categories on UIView and UIControl to give them new margin and size properties that will be stored in an ascociated object and in the setter call -setNeedsDisplay on the super view. I'll try to explore this :)

from masonry.

olegam avatar olegam commented on July 22, 2024

Seems to work very well with a UIView category to specify optional size and margin that can be referenced from the mas_updateConstraints method. Check out my example here: https://github.com/olegam/LiveLayoutDemo

What do you think of this approach? Something that would be suitable to ship wit Classy?

from masonry.

cloudkite avatar cloudkite commented on July 22, 2024

Glad it's working for you 👍
In terms of including it in classy I have some reservations, as I would rather not make classy and masonry dependent on each other for people who want to use one and not the other.

Also most of the time I would recommend using a custom UIView subclass so that you keep view logic out of your UIViewControllers.

from masonry.

olegam avatar olegam commented on July 22, 2024

Ok cool. And thanks again for the advice. I think I will then make a small pod with the category and write a blog post about the approach.

from masonry.

cloudkite avatar cloudkite commented on July 22, 2024

Sounds great! Looking forward to it :)

from masonry.

lluisgerard avatar lluisgerard commented on July 22, 2024

Looking forward too 👍 please, publish the link here, I love Masonry and is always nice to see how others use it!

from masonry.

olegam avatar olegam commented on July 22, 2024

Here's the link to my post: http://codeblog.shape.dk/blog/2013/12/16/live-editing-layout-constants-using-classy/

from masonry.

cloudkite avatar cloudkite commented on July 22, 2024

Thanks @olegam!

from masonry.

lluisgerard avatar lluisgerard commented on July 22, 2024

Amazing, thanks @olegam! 👍

from masonry.

vascoorey avatar vascoorey commented on July 22, 2024

Awesome one, cheers @olegam !

from masonry.

twlopes avatar twlopes commented on July 22, 2024

Very cool @olegam !

from masonry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.