marcoarment / compactconstraint Goto Github PK
View Code? Open in Web Editor NEWSimple NSLayoutConstraint expression parser for more readable autolayout code.
License: MIT License
Simple NSLayoutConstraint expression parser for more readable autolayout code.
License: MIT License
It seems that when called as a category on UIView, it would be nice to have @"self" as an implicit view (like @"super"), so that instead of this:
[_containerView addCompactConstraint:@"container.width = 320" metrics:nil views:@{@"container" : i_containerView}];
you could have:
[_containerView addCompactConstraint:@"self.width = 320" metrics:nil views:nil];
I would implement this by adding an (optional) selfView parameter to the NSLayoutConstraint category methods and using that from the UIView category methods, but it could also be done by having the UIView category "mutate" the views dictionary. The first method seems better, but it depends on how much you dislike adding either the parameter or more methods.
The current version accessible through CocoaPods release is a bit old and do not support priorities. Maybe releasing a new version could be a good thing.
iOS 8 added NSLayoutConstrain.identifier which can help making debugging constraints slightly less painful.
I was considering two additions to CompactConstraint for identifier support:
item1.attribute = item2.attribute + 10 (my identifier goes here)
?Number 2 seems pretty straightforward, but I wanted to see if there were any thoughts on syntax for specifying a custom identified before I embarked on number 1. Thoughts?
It appears that the parser don't expect whitespace after a constant
self.width = 0 @ 251
251 isn't parsed as priority.
self.width = 0@ 251
removing the leading space seems to work
With sufficient warnings enabled and NS_ENUM generating real enumerated types, there are warnings on the assignment of leftAttribute and leftAttribute from NSInteger (integerValue). Easily fixed with an explicit cast:
leftAttribute = (NSLayoutAttribute)[leftAttributeNumber integerValue];
rightAttribute = (NSLayoutAttribute)[rightAttributeNumber integerValue];
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.