Swift SF 符号背景颜色

问题描述 投票:0回答:1

我想将“原子”符号的背景图像设置为不透明的白色,并将其放在圆的中心。

目前我有两个单独的代码片段,无法解决如何设置符号的背景颜色或将图像放入 Circle() 内。

Image(systemName: "atom")
      .cornerRadius(25)
      .accentColor(.white.opacity(0.25))
      .frame(width: 50, height: 50)
Circle()
    .fill(.white.opacity(0.25))
    .frame(width: 50, height: 50)
swift sf-symbols
1个回答
0
投票

你可以尝试这个

.overlay
方法:

Circle()
    .fill(.white.opacity(0.25))
    .overlay {
        Image(systemName: "atom")
            .resizable()
            .cornerRadius(25)
            .frame(width: 50, height: 50)
    }
© www.soinside.com 2019 - 2024. All rights reserved.