Skip to content
This repository has been archived by the owner on Jul 15, 2018. It is now read-only.

marty-suzuki/LayoutGuaranteedView

Repository files navigation

LayoutGuaranteedView

CI Status Version License Platform Carthage compatible

LayoutGuaranteedView is a Phantom Type view holder. It guaranteed that a view had laid out after execute guaranteeLayout function.

Example

class ViewController: UIViewController {
    let viewHolder = ViewHolder<UITableView>(frame: .zero, style: .plain)

    override func viewDidLoad() {
        super.viewDidLoad()

        let guaranteedViewHolder = viewHolder.guaranteeLayout(addingTo: view,
                                                   layoutHandler: { tableView -> [NSLayoutConstraint] in
            return [
                tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
                tableView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor),
                tableView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor),
                tableView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
            ]
        })

        // guaranteedViewHolder.view returns `UITableView` instance
        guaranteedViewHolder.view.delegate = self
        guaranteedViewHolder.view.dataSource = self
    }
}

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Xcode 9 or greater
  • iOS 9 or greater
  • Swift 4

Installation

CocoaPods

LayoutGuaranteedView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'LayoutGuaranteedView'

Carthage

If you’re using Carthage, simply add SABlurImageView to your Cartfile:

github "marty-suzuki/LayoutGuaranteedView"

Make sure to add LayoutGuaranteedView.framework to "Linked Frameworks and Libraries" and "copy-frameworks" Build Phases.

Implementation

ViewHolder is a typealias of LayoutGuaranteedView_<LayouNotApplied, T>. After executing guaranteeLayout function, LayoutGuaranteedView_<LayouNotApplied, T> returns a LayoutGuaranteedView_<LayoutApplied, T> instance.

Author

marty-suzuki, s1180183@gmail.com

License

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

About

LayoutGuaranteedView is a Phantom Type view holder. It guaranteed that a view had laid out after execute `guaranteeLayout` function.

Resources

License

Stars

Watchers

Forks

Packages

No packages published