.nsfw()

SwiftUIViewsView Modifiersexamples

NSFW 代表「Not Safe For Work」,「上班不宜」的意思。這個例子可以用「觸控」來控制要不要將圖片模糊化。

struct ContentView: View {

    var body: some View {
        HStack {
            tiger
            Color.orange.aspectRatio(1, contentMode: .fit)
        }.frame(height: 300)
    }
    
    var tiger: some View {
        // 也可用 Image(playground: "...")
        Image(uiImage: #imageLiteral(resourceName: "tiger.heic"))
            .resizable()
            .scaledToFit()
            .shadow(radius: 4)
            .nsfw()                // ⭐️ view modifier: 🌀 .nsfw()
            .padding()
            .background(Color.gray)
    }
}

Last updated

Was this helpful?