1、添加边框
//第一种方法
TextView(text: $text)
.overlay(RoundedRectangle(cornerRadius: 4).stroke(Color.black))
//第二种方法
struct MonthView: View {
@Binding var activeMonth: Int
let label: String
let idx: Int
var body: some View {
Text(label)
.padding(10)
.onTapGesture { self.activeMonth = self.idx }
.background(MonthBorder(show: activeMonth == idx))
}
}
struct MonthBorder: View {
let show: Bool
var body: some View {
RoundedRectangle(cornerRadius: 15)
.stroke(lineWidth: 3.0).foregroundColor(show ? Color.red : Color.clear)
.animation(.easeInOut(duration: 0.6))
}
}
2、学习网站
https://stackoverflow.com/questions/47686008/design-preamble-mac-os-x-mas