您当前的位置: 首页 > 

LVGL 8.2 text shadow

发布时间:2022-07-03 09:12:57 ,浏览量:5

Create a fake text shadow
static void lv_example_label_2(void) { /*Create a style for the shadow*/ static lv_style_t style_shadow; lv_style_init(&style_shadow); lv_style_set_text_opa(&style_shadow, LV_OPA_30); lv_style_set_text_color(&style_shadow, lv_color_black()); /*Create a label for the shadow first (it's in the background)*/ lv_obj_t* shadow_label = lv_label_create(lv_scr_act()); lv_obj_add_style(shadow_label, &style_shadow, 0); /*Create the main label*/ lv_obj_t* main_label = lv_label_create(lv_scr_act()); lv_label_set_text(main_label, "A simple method to create\n" "shadows on a text.\n" "It even works with\n\n" "newlines and spaces."); /*Set the same text for the shadow label*/ lv_label_set_text(shadow_label, lv_label_get_text(main_label)); /*Position the main label*/ lv_obj_align(main_label, LV_ALIGN_CENTER, 0, 0); /*Shift the second label down and to the right by 2 pixel*/ lv_obj_align_to(shadow_label, main_label, LV_ALIGN_TOP_LEFT, 2, 2); } 
运行效果

在这里插入图片描述

  • 修改阴影透明度从LV_OPA_30改到LV_OPA_60
lv_style_set_text_opa(&style_shadow, LV_OPA_60); 
  • 运行效果 在这里插入图片描述
  • 修改阴影对齐坐标
lv_obj_align_to(shadow_label, main_label, LV_ALIGN_TOP_LEFT, 4, 4); 
  • 运行效果

在这里插入图片描述

关注
打赏
1688896170
查看更多评论

暂无认证

  • 5浏览

    0关注

    115984博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0759s