Skip to content

Instantly share code, notes, and snippets.

@backslash-f
Created January 14, 2020 08:43
Show Gist options
  • Save backslash-f/269998060f9468d57a533b50a4b26613 to your computer and use it in GitHub Desktop.
Save backslash-f/269998060f9468d57a533b50a4b26613 to your computer and use it in GitHub Desktop.
typealias + Function with return value
import SwiftUI
typealias Filter = (CGImage) -> CGImage
func blur(radius: Double) -> Filter {
return { image in
// Do something.
return image
}
}
let url = Bundle.main.url(forResource: "Landscape/Landscape_0", withExtension: "jpg")!
SImage().createImage(from: url) { cgImage in
if let image = cgImage {
let sameImage = blur(radius: 2.0)(image) // 👈🏻
sameImage
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment