struct ContentView: View {
var body: some View {
return RoundedRectangle(cornerRadius: 20).stroke().padding()
}
}
#.stroke(lineWidth: 3) stroke畫邊
#.stroke()放在形狀末尾將只填充邊緣,當卡片正面朝上時;我們希望它面朝下時填充。它面朝上時stroke才會執(zhí)行。stroke修飾和指定線條的寬度和顏色,stroke只能對形狀起作用,Text雖然是視圖但不是形狀。
#stroke 畫邊線內(nèi)外各占一半
#你也可以用.fill() 但這是默認值
struct ContentView: View {
var body: some View {
//alignment: .top 頂部對其,默認.center
// ZStack(alignment: .center) { 函數(shù)是最后一個參數(shù),可以省略
ZStack(alignment: .top, content: {
RoundedRectangle(cornerRadius: 20)
.stroke(lineWidth: 10)
Text("Hello World!")
.foregroundColor(.orange)
})
.padding()
//默認顏色
.foregroundColor(/*@START_MENU_TOKEN@*/.red/*@END_MENU_TOKEN@*/)
}
}
----------------
struct ContentView: View {
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 20)
.stroke(lineWidth: 10)
Text("Hello World!")
.foregroundColor(.orange)
}
.padding()
//默認顏色
.foregroundColor(/*@START_MENU_TOKEN@*/.red/*@END_MENU_TOKEN@*/)
}
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。