Created
July 31, 2023 03:36
-
-
Save dkun7944/2f793643e469029fb4e7d700f0645ffc to your computer and use it in GitHub Desktop.
AirDrop iOS 17 Swift.Shader Animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Airdrop Demo | |
// | |
// Created by Daniel Kuntz on 7/30/23. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
@State private var timer: Timer? | |
@State private var t: Float = 0.0 | |
private let shaderFunction = ShaderFunction(library: .default, name: "airdrop") | |
var body: some View { | |
VStack { | |
Image("mick") | |
.resizable() | |
.aspectRatio(contentMode: .fill) | |
.scaleEffect(x: 1.0, y: -1.0) | |
.layerEffect( | |
Shader(function: shaderFunction, | |
arguments: [ | |
.float(t), | |
.float2(Float(UIScreen.main.bounds.width), | |
Float(UIScreen.main.bounds.height)) | |
]), maxSampleOffset: CGSize(width: 800.0, height: 800.0) | |
) | |
} | |
.ignoresSafeArea() | |
.onAppear { | |
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { _ in | |
t = (t + 0.01).truncatingRemainder(dividingBy: 2.0) | |
}) | |
} | |
} | |
} | |
#Preview { | |
ContentView() | |
} |
This animation is so cool, thank you for sharing, Daniel!
It uses SwiftUI with ShaderFunction that's available only from iOS 17. I wonder, is it possible to use it with older versions of iOS with UIKit?
You’d have to render it using an MTKView. Bit more involved but definitely
possible
Пн, 9 окт. 2023 г. в 1:10 PM, Vladislav Samokhin ***@***.***>:
… ***@***.**** commented on this gist.
------------------------------
This animation is so cool, thank you for sharing, Daniel!
It uses SwiftUI with ShaderFunction that's available only from iOS 17. I
wonder, is it possible to use it with older versions of iOS with UIKit?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/dkun7944/2f793643e469029fb4e7d700f0645ffc#gistcomment-4719464>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAV7EVTD36FDRQLQ34GTLITX6RKZ5BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTEMZXG4ZTANBZU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Awesome, I'll find out, thank you for direction👍
The animation rendering is really bad. There seems to be something wrong with it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!