โœจ.destinationOut

import SwiftUI

public struct TestBlendModesView: View {
    public init(){}
    public var body: some View {
        HStack {
            // โญ blend mode ๆœƒ้€ๅˆฐๆœ€ๅบ•ๅฑคโ“
            ZStack {
                text
                myFrame
            }
            // โญ ๅฅ—็”จ shadow ๅพŒ blend mode ๆ•ˆๆžœๆถˆๅคฑโ“
            myFrame
                .shadow(radius: 8)        // โญ 
            // โญ ๅฅ—็”จ compositingGroup ๅฏไปฅ้˜ฒๆญข blend mode ้€ๅˆฐๅบ•ๅฑค
            ZStack {
                text
                myFrame
                    .compositingGroup()    // โญ 
                    .shadow(radius: 8)
            }
            // โญ Rectangle + stroke ไนŸๅฏไปฅๅพ—ๅˆฐใ€Œ้‚Šๆก†ใ€็š„ๆ•ˆๆžœ
            Rectangle()
                .strokeBorder(lineWidth: 16)    // โญ 
                .foregroundColor(.orange)
                .frame(width: 150, height: 150)
                .shadow(radius: 8)
        }
        .padding()
        .background(Color.gray)
    }
    
    var text: some View {
        Text("็Ž‹")
            .font(.system(size: 60))
            .bold()
            .foregroundColor(.pink)
    }
    
    var myFrame: some View {
        VStack {
            Color.green.overlay {
                Color.orange.opacity(0.85)
                    .padding()
                    .blendMode(.destinationOut)    // โญ ๆŒ–ๆดž
            }
        }
        .frame(width: 150, height: 150)
    }
}

Last updated