问题描述
通过设置代码的方式,当我的小部件在实际数据输入之前就被显示为占位符时,它看起来很丑陋,因为图像占位符被Circle()剪切路径切断了。
这是SwiftUI代码(第一个Image视图是有问题的视图):
var body: some View {
vstack {
HStack(alignment: .center,spacing: 14,content: {
Image(model.profileIcon).resizable()
.padding(4)
.frame(width: 44,height: 44)
.background(Color("LightColor"))
.clipShape(Circle())
vstack(alignment: .leading,spacing: 2,content: {
Text(model.profileName)
.font(.system(size: 16))
.bold()
Text("\(model.practicetoday) today")
.font(.system(size: 15)).fontWeight(.regular)
.foregroundColor(.gray)
})
Spacer()
})
Spacer()
Divider()
Spacer()
HStack(alignment: .center,spacing: 10,content: {
ForEach(0..<7) { i in
SimpleProgressCircle(
progress: CGFloat(model.progress[i]),day: model.weekdays[i],today: i == 6)
}
})
.padding(EdgeInsets(top: 0,leading: 2,bottom: 0,trailing: 2))
}
.padding(
EdgeInsets(top: 17,leading: 15,bottom: 20,trailing: 15))
.background(Color.foreground)
}
func placeholder(in context: Context) -> WidgetContent {
return WidgetContent(
profileID: "",profileName: "----",profileIcon: "",weekdays: ["","",""],progress: [0,0],practicetoday: "--"
)
}
理想的结果:占位符看起来像一个圆形,没有内部矩形
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)