openharmony 鸿蒙 ts-universal-attributes-foreground-blur-style

2025-06-12 浏览 (1)

Foreground Blur

You can apply foreground blur effects to a component.

NOTE

This attribute is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.

foregroundBlurStyle

foregroundBlurStyle(value: BlurStyle, options?: ForegroundBlurStyleOptions)

Applies a foreground blur style to the component.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
valueBlurStyleYesSettings of the foreground blur style.
optionsForegroundBlurStyleOptionsNoForeground blur options.

foregroundBlurStyle18+

foregroundBlurStyle(style: Optional<BlurStyle>, options?: ForegroundBlurStyleOptions, sysOptions?: SystemAdaptiveOptions)

Applies a foreground blur style to the component. Compared to foregroundBlurStyle, this API supports the undefined type for the style parameter.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
styleOptional<BlurStyle>YesSettings of the foreground blur style,
If style is set to undefined, no blur is applied.
optionsForegroundBlurStyleOptionsNoForeground blur options.
sysOptions18+SystemAdaptiveOptionsNoSystem adaptive adjustment options.
Default value: { disableSystemAdaptation: false }

ForegroundBlurStyleOptions

Inherited from BlurStyleOptions.

Atomic service API: This API can be used in atomic services since API version 12.

BlurStyleOptions

Defines the background blur options.

NameTypeMandatoryDescription
colorModeThemeColorModeNoColor mode used for the foreground blur.
Default value: ThemeColorMode.SYSTEM
Atomic service API: This API can be used in atomic services since API version 11.
adaptiveColorAdaptiveColorNoAdaptive color mode.
Default value: AdaptiveColor.DEFAULT
Atomic service API: This API can be used in atomic services since API version 11.
blurOptions11+BlurOptionsNoGrayscale blur parameters.
Default value: grayscale: [0,0]
Atomic service API: This API can be used in atomic services since API version 12.
scale12+numberNoForeground blur scale.
Default value: 1.0
Value range: [0.0, 1.0]
Atomic service API: This API can be used in atomic services since API version 12.

AdaptiveColor10+

Enumerates the adaptive color modes used for the background blur effect.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameDescription
DEFAULTAdaptive color mode is not used. The default color is used as the mask color. Using a mode other than DEFAULT can be more time-consuming.
AVERAGEAdaptive color mode is used. The average color value of the color picking area is used as the mask color.

BlurOptions11+

Grayscale blur parameters.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
grayscale[number, number]YesGrayscale blur, with two parameters in the value range of [0, 127]. The color gradation of the black and white in the image is adjusted to create different shades of gray. The first parameter indicates the brightness of the black color, and the second parameter indicates the darkness of the white color. A larger value indicates a more obvious adjustment effect (the black and white colors become grayer). For example, if the value specified is (20,20), the RGB value [0, 0, 0] (black) is converted to [20, 20, 20], RGB value [255, 255, 255] (white) is converted to [235, 235, 235] (255-20), and the color pixels remain unchanged.

Example

This example demonstrates how to apply content blur to an image using foregroundBlurStyle.

// xxx.ets
@Entry
@Component
struct ForegroundBlurStyleDemo {
  build() {
    Column() {
      Text('Thin Material').fontSize(30).fontColor(0xCCCCCC)
      Image($r('app.media.bg'))
        .width(300)
        .height(350)
        .foregroundBlurStyle(BlurStyle.Thin,
          { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
    }
    .height('100%')
    .width('100%')
  }
}

en-us_image_background_blur_style

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArcButton

harmony 鸿蒙ArcSlider

harmony 鸿蒙Chip

harmony 鸿蒙ChipGroup

harmony 鸿蒙ComposeListItem

harmony 鸿蒙ComposeTitleBar

harmony 鸿蒙advanced.Counter

harmony 鸿蒙Dialog Box (Dialog)

harmony 鸿蒙DialogV2

harmony 鸿蒙DownloadFileButton

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ri8sk7