๐ฒ How to Install
Using CocoaPods
Edit your Podfile
and specify the dependency:
pod 'MagicLayout', '~> 0.1.0'
๐ Features
- [x] Easy to install
- [x] Easy to use
- [x] Intuitive usage
- [x] Constraints by code in few minute
- [x] Less code! ๐
๐ How to use
1 - Import into your project
import MagicLayout
2 - Extends your ViewController from MagicViewController
class ViewController: MagicViewController
This is optional, you could call swift view.applyMagicConstrains()
in your view controller instead
3 - Set constaints to your views
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .favouriteColor
let myView = UIView()
myView.pin()
myView.backgroundColor = .secondFavColor
view.setPadding(padding: 40)
view.addSubview(myView)
}
and… voilร !
)
In few lines you could add a centered custom view in a superview with padding! ๐ฑ
๐ช Let’s the example code talks…
let myView = UIView()
myView.pinLeft()
myView.pinTop()
myView.setWidth(width: 200)
myView.setHeight(height: 50)
A fixed size view pinned to top left corner… Not bad at all, right? ๐ค
topView.matchWidth()
topView.pinTop()
topView.matchHeight(withPercentage: 50)
bottomView.matchWidth()
bottomView.pinBottom()
bottomView.matchHeight(withPercentage: 50)
Easy peasy ๐
๐งโโ๏ธOne more challenge to show you the POWER of Magic Layout! ๐ฅ
innerView.pin()
topView.matchWidth()
topView.pinTop()
topView.setPaddings(left: 10, right: 10, top: 30, bottom: 30)
topView.matchHeight(withPercentage: 50)
bottomView.matchWidth()
bottomView.pinBottom()
bottomView.matchHeight(withPercentage: 50)
view.addSubview(topView)
view.addSubview(bottomView)
topView.addSubview(innerView)
๐ It’s magic!
๐ Supported OS & SDK Versions
iOS 9.0+
Swift 4
xCode 9.2+
@Objc full compatibility
๐ฎ Project Example
This project include an example project using Magic Layout.
๐ Documentation & DevSite
โค Feedback
This is an open source project, so feel free to contribute. How?
- Fork this project and propose your own fixes, suggestions and open a pull request with the changes.