有两个视图UITableView和UIView。在将方向从纵向(70%:30%)更改为横向(0%:100%)后,我在尝试更改视图大小时遇到问题。 UITableView位于顶部,UIView位于底部。
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var graphView: GraphView!
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.current.orientation.isLandscape {
//tableView : graphView = 0% : 100%
tableView.frame.size.height = 0
graphView.frame.size.height = size.height
graphView.frame.size.width = size.width
} else {
//tableView : graphView = ~70% : ~30%
tableView.frame.size.height = size.height - 250
graphView.frame.size.height = 250
graphView.frame.size.width = size.width
}
}
}