-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SwiftyViewController added & Example Updated
- Loading branch information
1 parent
699e174
commit bc2dc60
Showing
2 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// SwiftyViewController.swift | ||
// | ||
// | ||
// Created by Mehmet Ateş on 17.11.2023. | ||
// | ||
|
||
import UIKit | ||
|
||
public protocol SwiftyViewControllerInferface { | ||
var content: UIView { get } | ||
func reDraw() | ||
func cleanDrawed() | ||
func draw() | ||
} | ||
|
||
public extension SwiftyViewControllerInferface where Self: UIViewController { | ||
func reDraw() { | ||
cleanDrawed() | ||
draw() | ||
} | ||
|
||
func cleanDrawed() { | ||
content.removeFromSuperview() | ||
view.subviews.forEach { $0.removeFromSuperview() } | ||
} | ||
|
||
func draw() { | ||
content | ||
.embedTo(view) | ||
.fillToSuperView() | ||
} | ||
} | ||
|
||
open class SwiftyViewController: UIViewController, SwiftyViewControllerInferface { | ||
public var content: UIView { view } | ||
open override func viewDidLoad() { | ||
super.viewDidLoad() | ||
draw() | ||
} | ||
} |