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
| /* | |
| File: UIImage+ImageEffects.h | |
| Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. | |
| Version: 1.0 | |
| Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple | |
| Inc. ("Apple") in consideration of your agreement to the following | |
| terms, and your use, installation, modification or redistribution of | |
| this Apple software constitutes acceptance of these terms. If you do | |
| not agree with these terms, please do not use, install, modify or |
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 UIViewController { | |
| func topMostViewController() -> UIViewController { | |
| if self.presentedViewController == nil { | |
| return self | |
| } | |
| if let navigation = self.presentedViewController as? UINavigationController { | |
| return navigation.visibleViewController.topMostViewController() | |
| } | |
| if let tab = self.presentedViewController as? UITabBarController { | |
| if let selectedTab = tab.selectedViewController { |
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
| // MARK: - UIImage (Base64 Encoding) | |
| public enum ImageFormat { | |
| case PNG | |
| case JPEG(CGFloat) | |
| } | |
| extension UIImage { | |
| public func base64(format: ImageFormat) -> String { |
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
| func getURL(ofPhotoWith mPhasset: PHAsset, completionHandler : @escaping ((_ responseURL : URL?) -> Void)) { | |
| if mPhasset.mediaType == .image { | |
| let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions() | |
| options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in | |
| return true | |
| } | |
| mPhasset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in | |
| completionHandler(contentEditingInput!.fullSizeImageURL) | |
| }) |
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
| // | |
| // StandardTooltip.swift | |
| // | |
| // Created by Albert Bori on 11/20/17. | |
| // | |
| import Foundation | |
| @objc | |
| class StandardTooltip: NSObject { |
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 { | |
| func blurred(radius: CGFloat) -> UIImage { | |
| let ciContext = CIContext(options: nil) | |
| guard let cgImage = cgImage else { return self } | |
| let inputImage = CIImage(cgImage: cgImage) | |
| guard let ciFilter = CIFilter(name: "CIGaussianBlur") else { return self } | |
| ciFilter.setValue(inputImage, forKey: kCIInputImageKey) | |
| ciFilter.setValue(radius, forKey: "inputRadius") | |
| guard let resultImage = ciFilter.value(forKey: kCIOutputImageKey) as? CIImage else { return self } |
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 UIView { | |
| /// Produce horizontal shake animation | |
| func shakeHorizontally(withCount count: Float = 4, duration: TimeInterval = 0.3, translation: Float = -10) { | |
| let animation: CABasicAnimation = CABasicAnimation(keyPath: "transform.translation.x") | |
| animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) | |
| animation.repeatCount = count | |
| animation.duration = (duration)/TimeInterval(animation.repeatCount) | |
| animation.autoreverses = true |
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 UIView { | |
| /// Sets rounded corners to the UIView | |
| func roundedCorners(radius: CGFloat? = nil) { | |
| if let radius = radius { | |
| layer.cornerRadius = radius | |
| } else { | |
| layer.cornerRadius = frame.size.height / 2 | |
| } | |
| clipsToBounds = true |
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 UIView { | |
| /// Produce vertical shake animation | |
| func shakeVertically(withCount count: Float = 4, duration: TimeInterval = 0.3, translation: Float = -10) { | |
| let animation: CABasicAnimation = CABasicAnimation(keyPath: "transform.translation.y") | |
| animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) | |
| animation.repeatCount = count | |
| animation.duration = (duration)/TimeInterval(animation.repeatCount) | |
| animation.autoreverses = true |
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 UIView { | |
| /// Sets border to the UIView | |
| func setViewBorder(withWidth width: CGFloat = 1.0, color: UIColor) { | |
| self.layer.borderWidth = width | |
| self.layer.borderColor = color.cgColor | |
| } | |
| } |
OlderNewer