Skip to content

Commit

Permalink
Merge pull request #11 from sagarmusale8/master
Browse files Browse the repository at this point in the history
Extension for UIViewController - to add view controller as child view…
  • Loading branch information
Esqarrouth committed Dec 19, 2015
2 parents 1420847 + ca26106 commit 8d208c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ override func viewDidAppear(animated: Bool) {

dismissVC(completion: nil) // Instead of dismissViewControllerAnimated(true, completion: completion)}
```

Easily add UIViewControllers:

``` swift
let myViewController = myViewController()
addAsChildViewController(myViewController, toView: self.anySubview) // Adding view controller as a child view controller to subview
```

##UIView Extensions

Easily initialize your objects:
Expand Down
8 changes: 8 additions & 0 deletions Sources/UIViewControllerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,13 @@ extension UIViewController {
public func dismissVC(completion completion: (() -> Void)? ) {
dismissViewControllerAnimated(true, completion: completion)
}

/// EZSwiftExtensions
public func addAsChildViewController(vc: UIViewController, toView: UIView){
vc.view.frame = toView.frame
toView.addSubview(vc.view)
self.addChildViewController(vc)
vc.didMoveToParentViewController(self)
}
}

0 comments on commit 8d208c0

Please sign in to comment.