Latest 1.0.3
Homepage https://github.com/Sroik/FunLayout
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

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_edges2.0

License

MIT license. See the LICENSE file for details.

Latest podspec

{
    "name": "FunLayout",
    "version": "1.0.3",
    "summary": "funny auto layout",
    "description": "FunLayout help you with autoLayout",
    "homepage": "https://github.com/Sroik/FunLayout",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Sroik": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Sroik/FunLayout.git",
        "tag": "1.0.3"
    },
    "frameworks": "UIKit",
    "source_files": "src/FunLayout/FunLayoutModule/*.{swift}"
}

Pin It on Pinterest

Share This