Skip to content

Commit 02f0f88

Browse files
committed
fix #4965
1 parent 52cc42a commit 02f0f88

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Reports/2025/#332-2025.04.21.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@
5252

5353
> 库,代码段,开源app
5454
55+
### 🐎 [Supercharging SwiftUI Text with Dynamic Content Styling](https://danielsaidi.com/blog/2025/04/08/supercharging-swiftui-text-with-dynamic-content-styling)
56+
57+
[@阿权](https://github.com/bqlin):文章提供了一种扩展 SwiftUI `Text` 视图的思路,通过自定义文本替换规则,允许对文本中的特定字符串(如单词或段落)应用自定义样式。核心实现包括:
58+
59+
1. `TextReplacementView`:提供单个或多个替换规则的初始化接口。
60+
2. `processReplacements`:查找文本中的匹配范围,按顺序处理非重叠替换,拼接生成带有不同样式的 `Text` 视图。
61+
62+
文章最后展示了简单和复杂场景下的用法,支持灵活的视图修饰符(如字体、颜色、斜体等)。其优势在于简化了原有通过组合多个 `Text` 视图实现样式定制的繁琐流程,提供了更统一的解决方案。
63+
64+
更详细的实现和用法可前往开源库 [TextReplacements](https://github.com/danielsaidi/TextReplacements)
65+
5566
##
5667

5768
> 比较不错的书的推荐和书评

0 commit comments

Comments
 (0)