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
| // Bad way using if statement | |
| func showMyView(bool: Bool) { | |
| if bool == true { | |
| UIView.animate(withDuration: 0.33, animations: { | |
| self.myView.alpha = 1.0 | |
| }) | |
| } else { | |
| UIView.animate(withDuration: 0.33, animations: { | |
| self.myView.alpha = 0.0 |
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
| extension UIProgressView { | |
| func animate(duration: Double) { | |
| setProgress(0.01, animated: true) | |
| UIView.animate(withDuration: duration, delay: 0.0, options: .curveLinear, animations: { | |
| self.setProgress(1.0, animated: true) | |
| }, completion: nil) | |
| } |
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
| if DeviceTypes.iPhone5 || DeviceTypes.iPhone7Zoomed { | |
| // Do any iPhone 5 (or iPhone7 Zoomed mode) specific code here | |
| } | |
| if DeviceTypes.iPhone7PlusStandard { | |
| // Do any iPhone 7 Plus specific code here | |
| } |
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 ScreenSize { | |
| static let SCREEN_WIDTH = UIScreen.main.bounds.size.width | |
| static let SCREEN_HEIGHT = UIScreen.main.bounds.size.height | |
| static let SCREEN_MAX_LENGTH = max(ScreenSize.SCREEN_WIDTH, ScreenSize.SCREEN_HEIGHT) | |
| static let SCREEN_MIN_LENGTH = min(ScreenSize.SCREEN_WIDTH, ScreenSize.SCREEN_HEIGHT) | |
| } | |
| struct DeviceTypes { | |
| static let iPhone4 = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREEN_MAX_LENGTH < 568.0 | |
| static let iPhone5 = UIDevice.current.userInterfaceIdiom == .phone && ScreenSize.SCREEN_MAX_LENGTH == 568.0 |
NewerOlder