mvm_core_ui/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift
Pfeil, Scott Robert 335ec160b5 swift
2020-03-13 10:04:47 -04:00

57 lines
1.8 KiB
Swift

//
// ProgrammaticScrollViewController.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 3/12/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class ProgrammaticScrollViewController: ScrollingViewController {
public var topConstraint: NSLayoutConstraint?
public var bottomConstraint: NSLayoutConstraint?
public override init(with scrollView: UIScrollView) {
super.init(with: scrollView)
}
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required public init?(coder: NSCoder) {
super.init(coder: coder)
}
open override func loadView() {
let view = UIView()
view.backgroundColor = .white
let scrollView = UIScrollView()
scrollView.backgroundColor = .clear
scrollView.translatesAutoresizingMaskIntoConstraints = true
view.addSubview(scrollView)
// Sets the constraints for the scroll view
let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: scrollView)
topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint
bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint
let contentView = MVMCoreUICommonViewsUtility.commonView()
scrollView.addSubview(contentView)
// Sets the constraints for the content view
NSLayoutConstraint.constraintPinSubview(toSuperview: contentView)
// Super will set later.
contentWidthConstraint = contentView.widthAnchor.constraint(equalToConstant: 320.0)
contentWidthConstraint?.isActive = true
self.contentView = contentView
self.scrollView = scrollView
self.view = view
}
}