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:

PropertyType

Required

Description
backgroundColorHexColorNo Window background color. For Android, this property is mandatory.
backgroundColorTopHexColorNoTop window background color, supported in iOS only.
backgroundColorBottomHexColorNoBottom window background color, supported in iOS only.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).