惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
S
SegmentFault 最新的问题
博客园 - 司徒正美
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
腾讯CDC
博客园 - 聂微东
D
DataBreaches.Net
博客园 - Franky
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
量子位
宝玉的分享
宝玉的分享
D
Docker
T
Tailwind CSS Blog
IT之家
IT之家
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
Project Zero
Project Zero
Microsoft Azure Blog
Microsoft Azure Blog
AWS News Blog
AWS News Blog
Google DeepMind News
Google DeepMind News
H
Heimdal Security Blog
W
WeLiveSecurity
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
NISL@THU
NISL@THU
C
Cybersecurity and Infrastructure Security Agency CISA
Google DeepMind News
Google DeepMind News
T
Threatpost
TaoSecurity Blog
TaoSecurity Blog
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
Recent Commits to openclaw:main
Recent Commits to openclaw:main
www.infosecurity-magazine.com
www.infosecurity-magazine.com
SecWiki News
SecWiki News
S
Securelist

Super Blog

[译] 我所知道的全部智能体工程技巧(2026 年 6 月) 2024:悲观者正确,乐观者前行 Overleaf LaTeX citation 无法正常显示问题解决 Mac 终端无法联网问题解决 我和我的 2023 新起点 使用 Arc 浏览器自定义网页 我和我的 2022 Genius Bar 两日游 实训小记 《软件测试技术》笔记 Q-Learning 简介 软件测试技术实验 3 和 4 遇到的一些问题和解决方案 我和我的 2021 写过的第二个 App 关于最近,以及…… 《数据库原理》笔记 《数字逻辑与数字系统》笔记 《形式化方法》笔记 宣言
在 SwiftUI 中自定义修饰器
SUPER · 2021-07-13 · via Super Blog

学习 swiftUI 的记录。

首先定义结构体,在其中对内容修饰:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct Watermark: ViewModifier {
var text: String

func body(content: Content) -> some View {
ZStack(alignment: .bottomTrailing) {
content
Text(text)
.font(.caption)
.foregroundColor(.white)
.padding(5)
.background(Color.black)
}
}
}

然后根据此结构体,定义 extension,在其中定义修饰器函数:

1
2
3
4
5
extension View {
func watermarked(with text: String) -> some View {
self.modifier(Watermark(text: text))
}
}

最终只需调用 extension 中的函数即可实现:

1
2
3
Color.green
.frame(width: 300, height: 200)
.watermarked(with: "Hacking with Swift")

效果图:

image-20210713104903030