Pull-to-Refresh API
Enable the native pull-to-refresh gesture in your iOS WebView app, customize its colors, and toggle it dynamically from your web app.
The Pull-to-Refresh API adds the native iOS pull-to-refresh gesture to your WebView app: users drag the page down to reload the current URL — just like in native apps such as Mail or Safari.
How to Enable:
Open Config.swift and set:
var pulltorefresh = true var preventoverscroll = false
pulltorefreshactivates the native refresh control.preventoverscrollmust be set tofalse— the gesture needs the WebView bounce/overscroll animation to work.
Customize the Colors:
You can style the loading spinner and its background separately for Light and Dark Mode in Config.swift:
var pulltorefresh_loadingsigncolour_lightmode = #colorLiteral(...) var pulltorefresh_backgroundcolour_lightmode = #colorLiteral(...) var pulltorefresh_loadingsigncolour_darkmode = #colorLiteral(...) var pulltorefresh_backgroundcolour_darkmode = #colorLiteral(...)
Tip: Click the color swatch next to each #colorLiteral in Xcode to pick a color visually. The Dark Mode variants require iOS 13 or higher.
Toggle Dynamically from Your Web App:
You can switch pull-to-refresh on or off at runtime — for example, to disable it on pages with their own swipe gestures (maps, sliders, games):
<a href="enablepulltorefresh://">Enable pull to refresh</a> <a href="disablepulltorefresh://">Disable pull to refresh</a>
Or via JavaScript:
window.location.href = "disablepulltorefresh://";
Both commands are also supported inside a MultiAPICall request.
Good to Know:
- The refresh control reloads the URL that is currently displayed in the WebView.
- If you use the Dynamic UI API to change the bottom bar color at runtime, the pull-to-refresh colors are adjusted automatically to match.