Skip to content

Commit 6773289

Browse files
authored
Merge pull request #165 from riveronly/main
fix(backgroundColor scrolling): ios add opaque param
2 parents 3767b3b + 12caae8 commit 6773289

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

webview/src/commonMain/kotlin/com/multiplatform/webview/setting/PlatformWebSettings.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ sealed class PlatformWebSettings {
188188
* IOS web settings
189189
*/
190190
data class IOSWebSettings(
191+
/**
192+
* The ios default opaque display
193+
* The default value is {@code false}.
194+
* When Value is true will turn off these two properties:
195+
* @param backgroundColor,@param underPageBackgroundColor
196+
*/
197+
var opaque: Boolean = false,
191198
/**
192199
* The background color of the WebView client. The default value is {@code null}.
193200
* Will use WebSettings backgroundColor when null.

webview/src/iosMain/kotlin/com/multiplatform/webview/web/WebView.ios.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ fun IOSWebView(
9797
)
9898
this.navigationDelegate = navigationDelegate
9999

100-
setOpaque(false)
101100
state.webSettings.let {
102101
val backgroundColor =
103102
(it.iOSWebSettings.backgroundColor ?: it.backgroundColor).toUIColor()
@@ -106,8 +105,11 @@ fun IOSWebView(
106105
it.iOSWebSettings.underPageBackgroundColor
107106
?: it.backgroundColor
108107
).toUIColor()
109-
setBackgroundColor(backgroundColor)
110-
scrollView.setBackgroundColor(scrollViewColor)
108+
setOpaque(it.iOSWebSettings.opaque)
109+
if (!it.iOSWebSettings.opaque) {
110+
setBackgroundColor(backgroundColor)
111+
scrollView.setBackgroundColor(scrollViewColor)
112+
}
111113
scrollView.pinchGestureRecognizer?.enabled = it.supportZoom
112114
}
113115
state.webSettings.iOSWebSettings.let {

0 commit comments

Comments
 (0)