WHC_AutoLayoutKit is a powerful and easy-to-use auto layout library for iOS projects. It simplifies the process of creating and managing Auto Layout constraints programmatically, making it more efficient and less error-prone compared to working with NSLayoutConstraint directly.
- Easy and expressive syntax for creating constraints
- Supports both UIView and NSLayoutAnchor
- Automatic constraint activation and deactivation
- Constraint multiplier and constant customization
- Programmatic constraint chaining
- Supports both Objective-C and Swift
You can install WHC_AutoLayoutKit through Cocoapods. Simply add the following line to your Podfile:
To use WHC_AutoLayoutKit in your project, follow these steps:
- Import the WHC_AutoLayoutKit module:
- Create the necessary constraints using the provided functions and operators:
// Examples: // Leading constraint viewA.whc_Leading.equalToSuperview().offset(10) // Height constraint viewB.whc_Height.equal(to: 50).priority(UILayoutPriority(800))
Here are a few code examples that demonstrate the usage of WHC_AutoLayoutKit:
// Example 1: Centering a view viewC.whc_CenterX.equalToSuperview() viewC.whc_CenterY.equalToSuperview() // Example 2: Constraint chaining viewD.whc_LeftSpaceEqual(viewC.whc_Right, offset: 10) viewD.whc_RightSpaceEqual(viewC.whc_Right) viewD.whc_TopSpaceEqual(viewC.whc_Bottom, offset: 20)
For detailed documentation and usage instructions, please refer to the official GitHub repository of WHC_AutoLayoutKit:
WHC_AutoLayoutKit is released under the MIT License. See the LICENSE file for more information.