Skip to content

sroik/FunLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FunLayout

Funny auto layout

codebeat badge

Introduction

  • Are U tired of the Apple's Auto Layout?
  • Yes!

That's is the main reason for creation FunLayout. FunLayout based on swift operators overloading.

##Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C/Swift, which automates and simplifies the process of using 3rd-party libraries like FunLayout in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate FunLayout into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

pod 'FunLayout', '~>1.0.3'

Then, run the following command:

$ pod install

Usage

Before use FunLayout, make sure that view.translatesAutoresizingMaskIntoConstraints is false, or set it to false

view.translatesAutoresizingMaskIntoConstraints = false

Alternatively U can use fun_prepareForLayout() function, which also clean all old constraints.

view.fun_prepareForLayout()

####To layout elements use the following formula:

firstItem.fun_attribute % priority {== or ~, <=, >=} secondItem.fun_attribute {*, /} multiplier {+, -} constant

U can use either == or ~, because they are equal.

Examples

import FunLayout

class ViewController: UIViewController {

    lazy var box = UIView()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(self.box)
        
        self.box.fun_prepareForLayout()
        self.box.fun_size == self.view
        self.box.fun_center == self.view
        
    }

}
  • To add fullscreen subview U can use one of the following:
view.fun_edges == superview // or view.fun_edges == superview.fun_edges

or

view.fun_size == superview  // or view.fun_size ~ superview.fun_edges
view.fun_center == superview //or view.fun_center ~ superview
  • Another examples
view.fun_top%750 == anotherView.fun_bottom

view.fun_top%950 ~ anotherView.fun_bottom // don't forget: == equal ~

view.fun_width == anotherView.fun_width*0.5 + 100.0

view.fun_height >= 100.0

view.fun_width <= 100.0

view.fun_edges == antherView.fun_edges\2.0

License

MIT license. See the LICENSE file for details.

About

fun auto layout

Resources

License

Stars

Watchers

Forks

Packages

No packages published