One-line chained Auto Layout for iOS views, labels and table cells
open sourceMITfree
SDAutoLayout is an Objective-C layout library for iOS that sets up a view's layout in one chained line (view.sd_layout.leftSpaceToView(...).topSpaceToView(...).heightIs(...)). Beyond positioning views relative to each other, it sizes UILabels to their text (including attributed text and a maximum number of lines), makes scroll views fit their content, and calculates and caches UITableView cell heights automatically, adjusting the cache when rows are inserted or deleted. It's installed with CocoaPods, and its README and support channels are in Chinese.
Problems it solves
- lay out iOS views in code without verbose NSLayoutConstraint calls
- make UITableView cells size themselves to their content in Objective-C
- auto-size a UILabel to its text in an Objective-C app
Features
- Chained one-line layout constraints on any view
- UILabel height and width that fit the text, including attributed text
- Automatic UITableView cell height calculation with caching
- Scroll views that size to their content
- Maximum, minimum and equal width and height constraints
