my.setBackgroundColor
Dynamically set window background color.
Supported types of mini programs: DSL, H5, H5+
Sample Code
DSL
copy
my.setBackgroundColor({
backgroundColor: '#ffffff',
backgroundColorTop: '#00ff00', //only for iOS
backgroundColorBottom: '#ff00ff', //only for iOS
success: function (res) {
console.log(res);
},
fail: function (err) {
console.log(err);
}
});H5, H5+
copy
AlipayJSBridge.call('setBackgroundColor', {
backgroundColor: '#ffffff',
backgroundColorTop: '#00ff00', //only for iOS
backgroundColorBottom: '#ff00ff', //only for iOS
}, function (res) {
my.alert({ title: 'AlipayJSBridge setBackgroundColor result', content: JSON.stringify(res, null, 2) });
});Parameters
The incoming parameter is of the Object type with the following attributes:
| Property | Type | Required | Description |
| backgroundColor | HexColor | No | Window background color. For Android, this property is mandatory. |
| backgroundColorTop | HexColor | No | Top window background color, supported in iOS only. |
| backgroundColorBottom | HexColor | No | Bottom window background color, supported in iOS only. |
| success | Function | No | Callback function upon call success. |
| fail | Function | No | Callback function upon call failure. |
| complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |