iPad support
This commit is contained in:
@@ -67,33 +67,41 @@ class BrowserView: UIView
|
||||
super.layoutSubviews()
|
||||
webView?.frame = bounds
|
||||
|
||||
if let toolbarView = toolbarView {
|
||||
var toolbarSize = toolbarView.sizeThatFits(bounds.size)
|
||||
|
||||
var bottomOffset: CGFloat = 0.0
|
||||
if keyboardLayoutOffset == 0 {
|
||||
toolbarSize.height += safeAreaInsets.bottom
|
||||
} else if toolbarView.urlBar?.textField.isFirstResponder ?? false {
|
||||
bottomOffset = keyboardLayoutOffset
|
||||
}
|
||||
|
||||
toolbarView.bounds = CGRect(origin: .zero, size: toolbarSize)
|
||||
toolbarView.center = CGPoint(x: bounds.center.x, y: bounds.maxY - (toolbarView.bounds.height / 2) - bottomOffset)
|
||||
}
|
||||
var webViewContentInset = UIEdgeInsets()
|
||||
|
||||
bringSubviewToFront(titlebarView)
|
||||
|
||||
var titlebarHeight: CGFloat = 24.0
|
||||
titlebarHeight += safeAreaInsets.top
|
||||
|
||||
titlebarView.frame = CGRect(origin: .zero, size: CGSize(width: bounds.width, height: titlebarHeight))
|
||||
webViewContentInset.top += titlebarView.frame.height
|
||||
|
||||
if let toolbarView = toolbarView {
|
||||
var toolbarSize = toolbarView.sizeThatFits(bounds.size)
|
||||
|
||||
// Compact: toolbar is at the bottom
|
||||
if traitCollection.horizontalSizeClass == .compact {
|
||||
var bottomOffset: CGFloat = 0.0
|
||||
if keyboardLayoutOffset == 0 {
|
||||
toolbarSize.height += safeAreaInsets.bottom
|
||||
} else if toolbarView.urlBar?.textField.isFirstResponder ?? false {
|
||||
bottomOffset = keyboardLayoutOffset
|
||||
}
|
||||
|
||||
toolbarView.bounds = CGRect(origin: .zero, size: toolbarSize)
|
||||
toolbarView.center = CGPoint(x: bounds.center.x, y: bounds.maxY - (toolbarView.bounds.height / 2) - bottomOffset)
|
||||
webViewContentInset.bottom += toolbarView.frame.height
|
||||
} else {
|
||||
// Regular: toolbar is at the top
|
||||
toolbarView.bounds = CGRect(origin: .zero, size: toolbarSize)
|
||||
toolbarView.center = CGPoint(x: bounds.center.x, y: titlebarView.center.y + titlebarView.frame.height)
|
||||
webViewContentInset.top += toolbarView.frame.height
|
||||
}
|
||||
}
|
||||
|
||||
// Fix web view content insets
|
||||
webView?.scrollView.automaticallyAdjustsScrollIndicatorInsets = false
|
||||
|
||||
var webViewContentInset = UIEdgeInsets()
|
||||
webViewContentInset.top = titlebarView.frame.height
|
||||
webViewContentInset.bottom = toolbarView?.frame.height ?? 0
|
||||
webView?.scrollView.contentInset = webViewContentInset.subtracting(safeAreaInsets)
|
||||
webView?.scrollView.scrollIndicatorInsets = webViewContentInset
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user