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
| import SwiftUI | |
| class DeviceSize { | |
| var scale: [CGFloat] { | |
| var silverRatioArray: [CGFloat] = [0] | |
| for i in 0 ... 21 { | |
| if i > 1 { | |
| silverArray[i] = silverArray[i - 1] * (1 + sqrt(2)) | |
| } else { |
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
| import SwiftUI | |
| import AVFoundation | |
| class Sound { | |
| var audioPlayer: AVAudioPlayer? | |
| func soundSetup() { | |
| do { | |
| try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.ambient) |
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
| import SwiftUI | |
| struct Motion { | |
| let motionEffectGroup: UIMotionEffectGroup = { | |
| let xMotion: UIInterpolatingMotionEffect = { | |
| let min = CGFloat(-30) | |
| let max = CGFloat(30) | |
| let xMotionSetting = UIInterpolatingMotionEffect(keyPath: "layer.transform.translation.x", type: .tiltAlongHorizontalAxis) |
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
| // | |
| // Orientation.swift | |
| // Code Template | |
| // | |
| // Created by Pao Yu on 2020-04-18. | |
| // Copyright © 2020 Yu Pao. All rights reserved. | |
| // | |
| import SwiftUI |
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
| // -------------------------------------------------------------------------------------- | |
| // How To Use Geometry Reader to Access Device Dimensions in SwiftUI | |
| // -------------------------------------------------------------------------------------- | |
| // Wrap the view code you wish to measure using the GeometryReader closure. | |
| // Using "device" will provide the most clarity to measuring device view dimensions. | |
| // Access the parent view's dimensions using "device.size.width" or "device.size.height" | |
| // Official Docs: https://developer.apple.com/documentation/swiftui/geometryreader | |
NewerOlder