Replace verbose NSLayoutConstraint code with compact chainable expressions for positioning iOS views
Automatically calculate and cache dynamic UITableViewCell heights based on their content
Make a UILabel resize its height to fit its text with a single method call
Adapt UIScrollView content size automatically based on the layout of its subviews
Installed via CocoaPods, requires Xcode and an iOS development environment.
SDAutoLayout is an Objective-C library for iOS that simplifies the process of positioning and sizing interface elements. In iOS development, Auto Layout is the system Apple provides for describing how views should arrange themselves relative to each other and to the screen. Writing these layout rules in raw Apple API calls tends to be verbose. SDAutoLayout replaces those calls with a chainable dot-notation style, so you can express the layout rules for a single view in one compact sequence of method calls. For example, you can place a view 10 points from the left of its parent, 80 points from the top, set a fixed height, and set its width as a proportion of its parent, all in a single chained expression. Methods follow a consistent naming pattern: those with SpaceToView accept a reference view and a distance, those with RatioToView accept a reference view and a multiplier, and those with Is accept a fixed value. The library also handles two situations that are otherwise tedious in iOS. First, table view cells whose height depends on their content: you call one method after setting up the cell layout and a second method in the table delegate to get the calculated value, with caching built in for performance. Second, labels whose height should adjust to fit the amount of text they display: one method call enables this. ScrollView content size adaptation is also supported, both vertically and horizontally. The library is available through CocoaPods for easy installation and is built on top of the Objective-C runtime. The README is primarily in Chinese and includes animated GIF demos, a changelog going back to 2015, links to video tutorials, and a reference to a complete WeChat-style demo app that shows the library used in a realistic project.
← gsdios on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.