65 lines
1.9 KiB
Swift
65 lines
1.9 KiB
Swift
//
|
|
// RDReaderPageChildViewController.swift
|
|
// RDReaderDemo
|
|
//
|
|
// Created by yangsq on 2021/8/9.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class RDReaderPageChildViewController: UIViewController {
|
|
private let contentContainerView = UIView()
|
|
var contentView: UIView? {
|
|
didSet {
|
|
guard isViewLoaded else { return }
|
|
installContentView()
|
|
}
|
|
}
|
|
var pageNum: Int = 0
|
|
init(contentView: UIView?, pageNum: Int = 0) {
|
|
self.contentView = contentView
|
|
self.pageNum = pageNum
|
|
super.init(nibName: nil, bundle: nil)
|
|
}
|
|
|
|
override func loadView() {
|
|
view = UIView()
|
|
view.backgroundColor = .clear
|
|
contentContainerView.frame = view.bounds
|
|
contentContainerView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
contentContainerView.backgroundColor = .clear
|
|
view.addSubview(contentContainerView)
|
|
installContentView()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
private func installContentView() {
|
|
contentContainerView.subviews.forEach { $0.removeFromSuperview() }
|
|
guard let contentView else { return }
|
|
contentView.removeFromSuperview()
|
|
contentView.frame = contentContainerView.bounds
|
|
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
contentContainerView.addSubview(contentView)
|
|
}
|
|
|
|
|
|
/*
|
|
// MARK: - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
// Get the new view controller using segue.destination.
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
}
|