#鸿蒙学习大百科#如何通过属性字符串实现文字阴影效果?

如何通过属性字符串实现文字阴影效果?

HarmonyOS
2024-10-26 09:48:27
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
天涯独一隅
import { LengthMetrics } from '@kit.ArkUI';

@Entry
@Component
struct Index {
  mutableStyledString: MutableStyledString = new MutableStyledString("运动35分钟", [
    {
      start: 0,
      length: 3,
      styledKey: StyledStringKey.TEXT_SHADOW,
      styledValue: new TextShadowStyle({
        radius: 5,
        type: ShadowType.COLOR,
        color: Color.Red,
        offsetX: 10,
        offsetY: 10
      })
    }
  ]);
  controller: TextController = new TextController();

  async onPageShow() {
    this.controller.setStyledString(this.mutableStyledString)
  }

  build() {
    Column() {
      // 显示属性字符串
      Text(undefined, { controller: this.controller })
    }
    .width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
分享
微博
QQ
微信
回复
2024-10-26 17:40:06
相关问题
#鸿蒙学习大百科#如何实现ui优化?
678浏览 • 1回复 待解决