diff --git a/ChattoAdditions/Source/Utils.swift b/ChattoAdditions/Source/Utils.swift index 3dee25d..cd2b73e 100644 --- a/ChattoAdditions/Source/Utils.swift +++ b/ChattoAdditions/Source/Utils.swift @@ -153,11 +153,11 @@ public extension UIImage { public func bma_tintWithColor(color: UIColor) -> UIImage { let rect = CGRect(origin: CGPoint.zero, size: self.size) UIGraphicsBeginImageContextWithOptions(rect.size, false, self.scale) - let context = UIGraphicsGetCurrentContext() + let context = UIGraphicsGetCurrentContext()! color.setFill() CGContextFillRect(context, rect) self.drawInRect(rect, blendMode: .DestinationIn, alpha: 1) - let image = UIGraphicsGetImageFromCurrentImageContext() + let image = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() return image.resizableImageWithCapInsets(self.capInsets) } @@ -165,16 +165,16 @@ public extension UIImage { public func bma_blendWithColor(color: UIColor) -> UIImage { let rect = CGRect(origin: CGPoint.zero, size: self.size) UIGraphicsBeginImageContextWithOptions(rect.size, false, UIScreen.mainScreen().scale) - let context = UIGraphicsGetCurrentContext() + let context = UIGraphicsGetCurrentContext()! CGContextTranslateCTM(context, 0, rect.height) CGContextScaleCTM(context, 1.0, -1.0) CGContextSetBlendMode(context, .Normal) - CGContextDrawImage(context, rect, self.CGImage) - CGContextClipToMask(context, rect, self.CGImage) + CGContextDrawImage(context, rect, self.CGImage!) + CGContextClipToMask(context, rect, self.CGImage!) color.setFill() CGContextAddRect(context, rect) CGContextDrawPath(context, .Fill) - let image = UIGraphicsGetImageFromCurrentImageContext() + let image = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() return image.resizableImageWithCapInsets(self.capInsets) } @@ -184,7 +184,7 @@ public extension UIImage { UIGraphicsBeginImageContextWithOptions(size, false, 0) color.setFill() UIRectFill(rect) - let image: UIImage = UIGraphicsGetImageFromCurrentImageContext() + let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() return image }