๐Ÿ“ฒ 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ร !

Screenshot iOS)

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

Magic Layout Documentation

โค 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.

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Author

Demian Tejo