-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce refreshControlTopAnchor property
- Loading branch information
Showing
6 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
diff --git a/Source/Visitable/VisitableView.swift b/Source/Visitable/VisitableView.swift | ||
index 12452b5..e9c37b8 100644 | ||
index 12452b5..49b932c 100644 | ||
--- a/Source/Visitable/VisitableView.swift | ||
+++ b/Source/Visitable/VisitableView.swift | ||
@@ -69,16 +69,6 @@ open class VisitableView: UIView { | ||
@@ -16,6 +16,8 @@ open class VisitableView: UIView { | ||
installActivityIndicatorView() | ||
} | ||
|
||
+ public var refreshControlTopAnchor: CGFloat = 0 | ||
+ | ||
// MARK: Web View | ||
|
||
open var webView: WKWebView? | ||
@@ -74,9 +76,17 @@ open class VisitableView: UIView { | ||
/// Otherwise fallback to 60 (the default height). | ||
let refreshControlHeight = refreshControl.frame.height > 0 ? refreshControl.frame.height : 60 | ||
|
||
#if !targetEnvironment(macCatalyst) | ||
scrollView.addSubview(refreshControl) | ||
- | ||
- /// Infer refresh control's default height from its frame, if given. | ||
- /// Otherwise fallback to 60 (the default height). | ||
- let refreshControlHeight = refreshControl.frame.height > 0 ? refreshControl.frame.height : 60 | ||
- | ||
- NSLayoutConstraint.activate([ | ||
- refreshControl.centerXAnchor.constraint(equalTo: centerXAnchor), | ||
+ let topAnchorConstraint: NSLayoutConstraint | ||
+ | ||
+ if (refreshControlTopAnchor > 0) { | ||
+ topAnchorConstraint = refreshControl.topAnchor.constraint(equalTo: webView!.topAnchor, constant: refreshControlTopAnchor) | ||
+ } else { | ||
+ topAnchorConstraint = refreshControl.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor) | ||
+ } | ||
+ | ||
NSLayoutConstraint.activate([ | ||
+ topAnchorConstraint, | ||
refreshControl.centerXAnchor.constraint(equalTo: centerXAnchor), | ||
- refreshControl.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor), | ||
- refreshControl.heightAnchor.constraint(equalToConstant: refreshControlHeight) | ||
- ]) | ||
refreshControl.heightAnchor.constraint(equalToConstant: refreshControlHeight) | ||
]) | ||
#endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters