🚫view.foreground()

此文作廢 ❗️

定義

swiftcustomextensionView.foreground()

.foregroundColor() 只能讓我們設定「前景色」,如果要套用諸如漸層這些比較花俏的東西時,就不行。因此,下面我們自己開發可以套用「任何 View」到前景的 extension。

有漸層顏色的文字
import SwiftUI
import PlaygroundSupport

struct ContentView: View {
    var body: some View {
        Text("SwiftUI is awesome!")
            .font(.largeTitle)
            .foreground(Gradient.horizontal(.red, .orange))
    }
}

PlaygroundPage.current.setLiveView(ContentView())

參考資料

Last updated

Was this helpful?