Skip to content

Commit

Permalink
transform 'ibSetView' to method which extends UIView to increase read…
Browse files Browse the repository at this point in the history
…ibility (#6)
  • Loading branch information
Adobels authored Oct 20, 2023
1 parent 0a59a9c commit cfe796a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Sources/UIViewKit/UIViewDSL+Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ enum UIViewDSLHelper {
}
}

extension UIViewController {

public func ibSetView<T: UIView>(with view: T, ibOutlet outlet: inout T?) {
ibSetView(with: view)
outlet = view
}
extension UIViewDSL {

public func ibSetView(with view: UIView) {
@discardableResult
public func ibSetAsRootView(of controller: UIViewController) -> Self {
guard let view = self as? UIView else {
fatalError()
}
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.frame = self.view.frame
view.frame = controller.view.frame
view.layoutIfNeeded()
self.view = view
controller.view = view
return self
}
}

0 comments on commit cfe796a

Please sign in to comment.