Created
May 15, 2020 16:17
-
-
Save stevencurtis/7d51a5a7c2096096212247f7e1aa75dc to your computer and use it in GitHub Desktop.
setup
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
import UIKit | |
class ViewController: UIViewController { | |
let subView = MyView() | |
var coverView = UIView() | |
var coverTopConstraint: NSLayoutConstraint! | |
var coverBottomConstraint: NSLayoutConstraint! | |
override func loadView() { | |
subView.backgroundColor = .red | |
self.view = subView | |
setupCover() | |
} | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
} | |
func setupCover() { | |
coverView.backgroundColor = .blue | |
self.view.addSubview(coverView) | |
coverView.translatesAutoresizingMaskIntoConstraints = false | |
coverTopConstraint = coverView.topAnchor.constraint(equalTo: self.view.topAnchor) | |
coverBottomConstraint = coverView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor) | |
NSLayoutConstraint.activate([ | |
coverBottomConstraint, | |
coverTopConstraint, | |
coverView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), | |
coverView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), | |
]) | |
} | |
} | |
class MyView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
} | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment