Swift Textに色付きの取り消し線をつけるサンプル

環境
Swift version 5.2.3 (swift-5.2.3-RELEASE)
Ubuntu 20.04.2 LTS

構文
Text(“文字列")
.strikethrough(color: 色)
strikethrough修飾子の引数「color」に色を指定します。
引数「color」に色を指定したstrikethrough修飾子を付与することで、Textに色付きの取り消し線をつけます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
struct ContentView: View {
var body: some View {
VStack {
Text("Study, Swiftskill")
.strikethrough(color: Color.yellow)
}
}
}
struct ContentView: View { var body: some View { VStack { Text("Study, Swiftskill") .strikethrough(color: Color.yellow) } } }
struct ContentView: View {
    var body: some View {
        VStack {
            Text("Study, Swiftskill")
                .strikethrough(color: Color.yellow)
        }
    }
}

 

Swift

Posted by arkgame