LayoutGuaranteedView is a Phantom Type view holder. It guaranteed that a view had laid out after execute guaranteeLayout
function.
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.
- Xcode 9 or greater
- iOS 9 or greater
- Swift 4
LayoutGuaranteedView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LayoutGuaranteedView'
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.
ViewHolder is a typealias of LayoutGuaranteedView_<LayouNotApplied, T>
.
After executing guaranteeLayout
function, LayoutGuaranteedView_<LayouNotApplied, T>
returns a LayoutGuaranteedView_<LayoutApplied, T>
instance.
marty-suzuki, s1180183@gmail.com
LayoutGuaranteedView is available under the MIT license. See the LICENSE file for more info.