Symbol Glyph Modifier
SymbolGlyphModifier is used to dynamically set the attributes and styles of the SymbolGlyph component. The if/else statements can be used. SymbolGlyph is a component used to display symbol glyphs.
NOTE
The initial APIs of this module are supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version.
SymbolGlyphModifier
Defines the SymbolGlyphModifier.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
constructor
constructor(src?: Resource)
A constructor used to create a SymbolGlyphModifier object.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| src | Resource | No | Resource information. |
applyNormalAttribute
applyNormalAttribute?(instance: SymbolGlyphAttribute): void
Applies the style of a component in the normal state.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| instance | SymbolGlyphAttribute | Yes | Dynamic attribute setting for the SymbolGlyph component. |
Example
This example demonstrates how to use SymbolGlyphModifier and the cancelButton attribute of the TextInput component to customize the style of the symbol-type cancel button on the right side of the text box.
import { SymbolGlyphModifier } from '@kit.ArkUI';
// xxx.ets
@Entry
@Component
struct Index {
@State text: string = '';
symbolModifier: SymbolGlyphModifier =
new SymbolGlyphModifier($r('sys.symbol.trash')).fontColor([Color.Red]).fontSize(16).fontWeight(FontWeight.Regular);
build() {
Column() {
TextInput({ text: this.text, placeholder: 'input your word...' })
.height(50)
.cancelButton({
style: CancelButtonStyle.CONSTANT,
icon: this.symbolModifier // The symbol type is supported since API version 18.
})
}.margin(10)
}
}
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 ts-drawing-components-shape
openharmony 鸿蒙 ts-universal-attributes-sharp-clipping
openharmony 鸿蒙 ts-universal-attributes-toolbar
openharmony 鸿蒙 ts-container-lazyvgridlayout
openharmony 鸿蒙 ohos-arkui-advanced-FoldSplitContainer
openharmony 鸿蒙 ts-methods-calendarpicker-dialog
openharmony 鸿蒙 ts-uicommonevent
openharmony 鸿蒙 ts-basic-gestures-tapgesture