前景色設(shè)置
設(shè)置組件的前景色。
說(shuō)明:
開(kāi)發(fā)前請(qǐng)熟悉鴻蒙開(kāi)發(fā)指導(dǎo)文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md
]
從API Version 10開(kāi)始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。
屬性
名稱(chēng) | 參數(shù)類(lèi)型 | 描述 |
---|---|---|
foregroundColor | [ResourceColor] | [ColoringStrategy] |
示例
示例1
// xxx.ets
@Entry
@Component
struct ForegroundColorExample {
build() {
Column({ space: 100 }) {
// 繪制一個(gè)直徑為150的圓,默認(rèn)填充色為黑色
Circle({ width: 150, height: 200 })
// 繪制一個(gè)直徑為150的圓,
Circle({ width: 150, height: 200 }).foregroundColor(Color.Red)
}.width('100%').backgroundColor(Color.Blue)
}
}
示例2
// xxx.ets
@Entry
@Component
struct ColoringStrategyExample {
build() {
Column({ space: 100 }) {
// 繪制一個(gè)直徑為150的圓,默認(rèn)填充色為黑色
Circle({ width: 150, height: 200 })
// 繪制一個(gè)直徑為150的圓,設(shè)置前景色為組件背景色的反色
Circle({ width: 150, height: 200 })
.backgroundColor(Color.Black)
.foregroundColor(ColoringStrategy.INVERT)
}.width('100%')
}
}
示例3
`HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿`
// xxx.ets
@Entry
@Component
struct foregroundColorInherit {
build() {
Column() {
Button('設(shè)置前景色為橘色').fontSize(20).foregroundColor(Color.Orange).backgroundColor(Color.Gray)
Divider()
Button('未設(shè)置前景色繼承自父組件').fontSize(20).backgroundColor(Color.Gray)
}.foregroundColor(Color.Red)
}
}
審核編輯 黃宇
-
鴻蒙
+關(guān)注
關(guān)注
57文章
2392瀏覽量
43050
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論