File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ open class VisitableView: UIView {
45
45
46
46
open lazy var refreshControl : UIRefreshControl = {
47
47
let refreshControl = UIRefreshControl ( )
48
+ refreshControl. translatesAutoresizingMaskIntoConstraints = false
48
49
refreshControl. addTarget ( self , action: #selector( refresh ( _: ) ) , for: . valueChanged)
49
50
return refreshControl
50
51
} ( )
@@ -67,13 +68,21 @@ open class VisitableView: UIView {
67
68
guard let scrollView = webView? . scrollView, allowsPullToRefresh else { return }
68
69
69
70
#if !targetEnvironment(macCatalyst)
70
- scrollView. refreshControl = refreshControl
71
+ scrollView. addSubview ( refreshControl)
72
+
73
+ let height = refreshControl. frame. height > 0 ? refreshControl. frame. height : 60
74
+
75
+ NSLayoutConstraint . activate ( [
76
+ refreshControl. centerXAnchor. constraint ( equalTo: centerXAnchor) ,
77
+ refreshControl. topAnchor. constraint ( equalTo: safeAreaLayoutGuide. topAnchor) ,
78
+ refreshControl. heightAnchor. constraint ( equalToConstant: height)
79
+ ] )
71
80
#endif
72
81
}
73
82
74
83
private func removeRefreshControl( ) {
75
84
refreshControl. endRefreshing ( )
76
- webView ? . scrollView . refreshControl = nil
85
+ refreshControl. removeFromSuperview ( )
77
86
}
78
87
79
88
@objc func refresh( _ sender: AnyObject ) {
You can’t perform that action at this time.
0 commit comments