CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

FluidAnchor 0.1.0

FluidAnchor 0.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by EasyMakePhotoPicker.



  • By
  • audrl1010




FluidAnchor is a framework that makes it easy to use Auto Layout Anchor. 🤗

Requirements

  • iOS 9.0+

Installation

pod 'FluidAnchor'

Usage

Quick Start

import FluidAnchor

class ViewController: UIViewController {

  var tableView = UITableView()
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    self.view.addSubview(tableView)
    
    tableView.flu
      .topAnchor(equalTo: view.safeAreaLayoutGuide.topAnchor)
      .leftAnchor(equalTo: view.safeAreaLayoutGuide.leftAnchor)
      .rightAnchor(equalTo: view.safeAreaLayoutGuide.rightAnchor)
      .bottomAnchor(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
  }
}

Tip

Constant

import FluidAnchor

class ProfileViewController: UIViewController {
  var profileImageView = UIImageView()
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    self.view.addSubview(profileImageView)
    
    profileImageView.flu
      .topAnchor(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 5)
      .leftAnchor(equalTo: view.leftAnchor, constant: 10)
      .heightAnchor(equalToConstant: 50)
      .widthAnchor(equalToConstant: 50)
  }
}

Animation

import FluidAnchor

class ChatVC: UIViewController {

  var inputBar = InputBar()
  
  var inputBarBottomConstraint: NSLayoutConstraint?
  
  override func viewDidLoad() {
    ...
    // You can specify the constraint to use later when animating.
    inputBar.flu
      .bottomAnchor(
        equalTo: view.safeAreaLayoutGuide.bottomAnchor,
        constraint: &inputBarBottomConstraint
      )
    ...
  }
  
  ...
  func keyboardWillShow(_ notification: Notification) {
    ...
    inputBarBottomConstraint?.constant = (someting value)
    
    UIView.animate(withDuration: keyboardDuration) {
      view.layoutIfNeeded()
    }
    ...
  }
  ...
}

Author

🇰🇷Myung gi son, [email protected]

License

FluidAnchor is available under the MIT license. See the LICENSE file for more info.