This file contains hidden or 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
| func playAHAP(_ name: String) { | |
| guard | |
| let engine = try? CHHapticEngine(), | |
| let url = Bundle.main.url(forResource: name, withExtension: "ahap") | |
| else { return } | |
| try? engine.start() | |
| let player = try? engine.makePlayer(with: CHHapticPattern(contentsOf: url)) | |
| try? player.start(atTime: CHHapticTimeImmediate) | |
| } |
This file contains hidden or 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
| let event = CHHapticEvent( | |
| eventType: .hapticContinuous, | |
| parameters: [ | |
| CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0), | |
| CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0), | |
| ], | |
| relativeTime: 0, | |
| duration: 60 | |
| ) |
This file contains hidden or 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
| override func layoutSubviews() { | |
| super.layoutSubviews() | |
| let filter = (NSClassFromString("CAFilter") as! NSObject.Type) | |
| .perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")! | |
| .takeUnretainedValue() as! NSObject | |
| filter.setValue(20, forKey: "inputRadius") | |
| filter.setValue(makeMaskImage(), forKey: "inputMaskImage") | |
| filter.setValue(true, forKey: "inputNormalizeEdges") |
This file contains hidden or 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
| private final class VariableBlurUIView: UIVisualEffectView { | |
| override func layoutSubviews() { | |
| super.layoutSubviews() | |
| let filter = (NSClassFromString("CAFilter") as! NSObject.Type) | |
| .perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")! | |
| .takeUnretainedValue() as! NSObject | |
| filter.setValue(20, forKey: "inputRadius") | |
| filter.setValue(makeMaskImage(), forKey: "inputMaskImage") |
This file contains hidden or 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
| struct ProgressiveBlurView: UIViewRepresentable { | |
| func makeUIView(context: Context) -> UIVisualEffectView { | |
| VariableBlurUIView(effect: UIBlurEffect(style: .light)) | |
| } | |
| func updateUIView(_ view: UIVisualEffectView, context: Context) {} | |
| } |
This file contains hidden or 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
| func makeUIView(context: Context) -> UIVisualEffectView { | |
| let view = UIVisualEffectView(effect: UIBlurEffect(style: .light)) | |
| let filter = (NSClassFromString("CAFilter") as! NSObject.Type) | |
| .perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")! | |
| .takeUnretainedValue() as! NSObject | |
| filter.setValue(20, forKey: "inputRadius") | |
| view.subviews.first?.layer.filters = [filter] | |
| return view | |
| } |
This file contains hidden or 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
| struct ProgressiveBlurView: UIViewRepresentable { | |
| func makeUIView(context: Context) -> UIVisualEffectView { | |
| UIVisualEffectView(effect: UIBlurEffect(style: .light)) | |
| } | |
| func updateUIView(_ view: UIVisualEffectView, context: Context) { | |
| view.effect = UIBlurEffect(style: .light) | |
| } | |
| } |
This file contains hidden or 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
| struct ProgressiveBlurView: UIViewRepresentable { | |
| func makeUIView(context: Context) -> UIVisualEffectView { | |
| UIVisualEffectView(effect: UIBlurEffect(style: .systemThinMaterialLight)) | |
| } | |
| func updateUIView(_ view: UIVisualEffectView, context: Context) { | |
| view.effect = UIBlurEffect(style: .systemThinMaterialLight) | |
| } | |
| } |
This file contains hidden or 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
| var body: some View { | |
| ScrollView { | |
| // ... | |
| } | |
| .overlay(alignment: .top) { | |
| Text("Design Kisses") | |
| .font(.system(.headline, design: .rounded)) | |
| .frame(maxWidth: .infinity) | |
| .padding(.vertical, 12) | |
| .background { |
NewerOlder