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 AVSpeechSynthesisVoice { | |
class func currentLanguageCodeWorkaround() -> String { | |
if #available(iOS 13, *) { | |
for preferredLanguage in Locale.preferredLanguages { | |
let locale = Locale(identifier: preferredLanguage) | |
if let languageCode = locale.languageCode { | |
var voiceLanguage = languageCode | |
if let regionCode = locale.regionCode { |
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 extension UIView { | |
private struct Static { | |
static let initialize: (AnyClass) -> Void = { (aClass: AnyClass!) in | |
let swizzle: (Selector, Selector) -> Void = { (original, swizzled) in | |
let originalSelector = original | |
let swizzledSelector = swizzled | |
let originalMethod = class_getInstanceMethod(aClass, originalSelector) | |
let swizzledMethod = class_getInstanceMethod(aClass, swizzledSelector) |
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
// Convert an EXIF image orientation to an iOS one. | |
// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html | |
+ (UIImageOrientation) exifOrientationToiOSOrientation:(int)exifOrientation { | |
UIImageOrientation o = UIImageOrientationUp; | |
switch (exifOrientation) { | |
case 1: o = UIImageOrientationUp; break; | |
case 3: o = UIImageOrientationDown; break; | |
case 8: o = UIImageOrientationLeft; break; | |
case 6: o = UIImageOrientationRight; break; |