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
| - (UIImage *)fixRotation | |
| { | |
| if (self.imageOrientation == UIImageOrientationUp) return self; | |
| CGAffineTransform transform = CGAffineTransformIdentity; | |
| switch (self.imageOrientation) { | |
| case UIImageOrientationDown: | |
| case UIImageOrientationDownMirrored: | |
| transform = CGAffineTransformTranslate(transform, self.size.width, self.size.height); | |
| transform = CGAffineTransformRotate(transform, M_PI); |
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 UIImage { | |
| public func imageRotatedByDegrees(degrees: CGFloat) -> UIImage { | |
| let radiansToDegrees: (CGFloat) -> CGFloat = { | |
| return $0 * (180.0 / CGFloat(M_PI)) | |
| } | |
| let degreesToRadians: (CGFloat) -> CGFloat = { | |
| return $0 / (180.0 * CGFloat(M_PI)) | |
| } | |
| // calculate the size of the rotated view's containing box for our drawing space |
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 UIKit | |
| import Security | |
| class Keychain { | |
| class func save(key: String, data: NSData) -> Bool { | |
| let query: [String: AnyObject] = [ | |
| kSecClass : kSecClassGenericPassword, | |
| kSecAttrAccount : key, | |
| kSecValueData : data ] |