Type Function Object NativeDisplayObject Library native.* Return value none Revision Release 2024.3703 Keywords native object, property accessors See also object:getNativeProperty()
This function allows you to set properties of the underlying native object created by the native library. For example, if you create a WebView on iOS, you can set the Obj-C properties of the corresponding WKWebView
or WKWebViewConfiguration
if called before a request is made. Similarly on Android it can set properties of WebView
or WebSettings
object:setNativeProperty( property, value )
String. The string name for the native property.
The value to set the property to. Must be a Lua value compatible with
Android also supports special pair of values for WebView: property "http.agent"
and value "system"
to set WebView user agent to system default.
local webView = native.newWebView( 0, 0, display.contentWidth, display.contentHeight ) if system.getInfo("platform") == "android" then webView:setNativeProperty("http.agent", "system") webView:setNativeProperty("setBuiltInZoomControls", false) else webView:setNativeProperty( "allowsInlineMediaPlayback", true ) end webView:request( "https://www.solar2d.com" )