-
Notifications
You must be signed in to change notification settings - Fork 736
Migrating from PureLayout v1.x to v2.0
PureLayout v2.0.0 is a major milestone release. It brings an extensive set of enhancements and improvements to the library. See the release notes for an overview of changes.
Just like v1.x.x, PureLayout v2.0.0 maintains full backwards compatibility with Xcode 5, and supports deployment targets all the way back to iOS 6 and OS X 10.7. Note that some of the new APIs require the iOS 8 SDK (so they will not be available to use in Xcode 5), and these new APIs require iOS 8 to run (with the exception of the constraint identifier APIs, which can also be used on iOS 7). Please reference the source code's documentation of the new APIs for further discussion of availability.
While most of the changes in PureLayout v2.0.0 are either completely new APIs or internal enhancements, there are a few breaking changes that will impact users of v1.x.x
-
-[UIView autoRemoveConstraintsAffectingView...]
(and related methods) These methods have been deprecated. They encourage bad practices, and while often effective and convenient, can cause serious performance issues. These methods will be removed entirely in a future version of the library. Retain a reference to and remove specific constraints instead, or recreate the view(s) entirely to remove all constraints.
-
+[UIView autoRemoveConstraint:]
This method has been removed. Use-[NSLayoutConstraint autoRemove]
instead, which works identically. -
+[UIView autoRemoveConstraints:]
This method has been removed. Use-[NSArray autoRemoveConstraints]
instead, which works identically.
-
-[UIView autoConstrainAttribute:toAttribute:ofView:]
(and related methods) These methods used to take attribute parameters of type NSInteger (expecting an ALEdge, ALAxis, or ALDimension). The new API expects attributes of type ALAttribute, which is a new combined enum type that is effectively a union of all the more specific attribute types. As such, you may either use an ALAttribute constant instead, or you may cast from a specific attribute type to the more generic ALAttribute (e.g.(ALAttribute)ALEdgeTop
). (Note that casting from ALAttribute to a more specific type is not necessarily safe.) -
-[NSArray autoDistributeViewsAlongAxis:...]
These methods have had thealignment:
parameter moved from the last parameter, to the second parameter asalignedTo:
. Instead of taking one of the NSLayoutFormatOptions, thealignedTo:
parameter now takes an ALAttribute. As mentioned, it is safe to cast from a specific attribute type to the more generic ALAttribute.