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
| Yourarray.append([labeltext]) | |
| tableView.beginUpdates() | |
| tableView.insertRows(at: [IndexPath(row: yourArray.count-1, section: 0)], with: .automatic) | |
| tableView.endUpdates() |
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 { | |
| enum JPEGQuality: CGFloat { | |
| case lowest = 0 | |
| case low = 0.25 | |
| case medium = 0.5 | |
| case high = 0.75 | |
| case highest = 1 | |
| } | |
| /// Returns the data for the specified image in PNG format |
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 CompressionService { | |
| /** | |
| compress 'image' to 'maxSize' size | |
| - Parameter image: The image to compress. | |
| - Parameter maxSize: The maximum size in MB to image. | |
| - Returns: A Data image with 'maxSize' applied. | |
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
| UIView.transition(with: self.imageView, | |
| duration:0.5, | |
| options: .transitionCrossDissolve, | |
| animations: { self.imageView.image = newImage }, | |
| 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
| extension UIImageView { | |
| func changeImage(to newImage: UIImage?) { | |
| let crossFade: CABasicAnimation = CABasicAnimation(keyPath: "contents") | |
| crossFade.duration = 0.2 | |
| crossFade.fromValue = self.image?.cgImage | |
| crossFade.toValue = newImage?.cgImage | |
| self.image = newImage | |
| self.layer.add(crossFade, forKey: "animateContents") | |
| } | |
| } |
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 | |
| public enum Shape { | |
| case rectangle | |
| case rounded(CGFloat) | |
| case circular | |
| } | |
| extension UIView { | |
| @IBInspectable var cornerRadius: CGFloat { |
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
| let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil) | |
| let controller = storyboard.instantiateViewController(withIdentifier: "someViewController") | |
| self.present(controller, 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
| guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else { return } | |
| if UIApplication.shared.canOpenURL(settingsUrl) { | |
| UIApplication.shared.open(settingsUrl, completionHandler: { (success) in | |
| print("Settings opened: \(success)") // Prints 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
| import UIKit | |
| class RootVC: UITabBarController { | |
| //MARK: - Propertise | |
| let selectedColor = UIColor(red: 238 / 255.0, green: 110 / 255.0, blue: 115 / 255.0, alpha: 1) | |
| let unselectedColor = UIColor(red: 37 / 255.0, green: 37 / 255.0, blue: 37 / 255.0, alpha: 1) | |
| //MARK: - Life cycle |
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 UITabBarController { | |
| func removeTabbarItemsText() { | |
| tabBar.items?.forEach { | |
| $0.title = "" | |
| $0.imageInsets = UIEdgeInsets(top: 6, left: 0, bottom: -6, right: 0) | |
| } | |
| } | |
| } |
OlderNewer