一、控件中常用文本格式 RichText
二、效果展示

三、关键代码
use eframe::egui;
use egui::{Color32, RichText};ui.heading(RichText::new("标题,颜色红色,字体大小40").color(Color32::RED).size(40.0),
); ui.add(egui::Button::new(RichText::new("按钮,颜色蓝色,字体大小30").strong().color(Color32::from_rgb(0, 0, 255)).size(30.0),),
);
ui.label(RichText::new("标签,颜色绿色,透明度为100,字体大小20").color(Color32::from_rgba_premultiplied(0, 250, 0, 100)).size(20.0),
);
ui.label(RichText::new("标签,背景色黄色,字体大小15").background_color(Color32::YELLOW).size(15.0),
);
ui.label(RichText::new("字间距:30").extra_letter_spacing(30.0));
ui.label(RichText::new("标题样式").heading());
ui.label(RichText::new("斜体").italics());
ui.label(RichText::new("行高,文本顶部到下一行的距离").line_height(Some(25.0)));
ui.label(RichText::new("下划线").underline());
ui.label(RichText::new("删除线").strikethrough());
ui.label(RichText::new("小字体").small());
ui.label(RichText::new("加粗").strong());
ui.label(RichText::new("减弱").weak());