SwiftUI Metal Shader API in iOS 17

In WWDC 23, Apple released new APIs for SwiftUI. The coolest one is the Metal Shader API, which allows us to directly access the SwiftUI layer in Metal Shaders and build some immersive cool animations using SwiftUI. The Metal Shader can be easily integrated into any SwiftUI view by simply calling these modifiers:
  • .layerEffect(shader: <Shader>, maxSampleOffset: <GSize>)
  • .distortionEffect(shader: <Shader>, maxSampleOffset: <CGSize>)
We cannot call these modifiers directly. First, we need to use the .visualEffect() modifier. Inside the visual effect modifier, we can call these Metal SwiftUI Modifiers.
I've used these methods to create some shader animations. Check out the gif below for reference.
notion image
For more information about the implementation, check out this YouTube video.
Video preview
 

Support meYour support would really help us on creating new videos about SwiftUI Everyday. Thank you.

Copyright © Kavsoft 2020 - 2023