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
| 01. Begin by declaring that the View Controller class implements the | |
| UIImagePickerControllerDelegate and UINavigationControllerDelegate protocols, | |
| then within the ViewController.swift file implement the code as follows: | |
| class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
| . | |
| . | |
| @IBAction func selectPhoto(_ sender: AnyObject) { | |
| let imagePicker = UIImagePickerController() |
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
| // See: https://stackoverflow.com/questions/32281651/how-to-dismiss-keyboard-when-touching-anywhere-outside-uitextfield-in-swift | |
| override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { | |
| self.view.endEditing(true) | |
| } | |
| // For specific fields you can try: | |
| override func touchesBegan(_ touches: Set<UITouch>, | |
| with event: UIEvent?) { |
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
| See: https://www.appcoda.com/cloudkit-introduction-tutorial/ | |
| 01. Declare: | |
| var imageURL: NSURL! | |
| let documentsDirectoryPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! NSString | |
| let tempImageName = "temp_image.jpg" | |
| 02. Create a custom method |
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
| Source: BorgGreen | |
| func drawLine(xorig: CGFloat, yorig: Int, xlen: Int, ylen: Int, color: CGColor) { | |
| let doYourPath = UIBezierPath(rect: CGRect(x: Int(xorig), y: yorig, width: xlen, height: ylen)) | |
| let layer = CAShapeLayer() | |
| layer.path = doYourPath.cgPath | |
| layer.strokeColor = color | |
| layer.fillColor = color |
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
| //See: https://stackoverflow.com/questions/43073623/changing-the-color-of-the-status-bar | |
| Source: BorgGreen | |
| 01. First in Plist set View controller-based status bar appearance to NO | |
| 02. Add this code to AppDelegate.swift | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| // Set Status Bar to light colour for ALL ViewControllers |
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
| See: http://purelywebdesign.co.uk/tutorial/swift-underlined-text-field-tutorial/ | |
| Source: BorgGreen | |
| 01. EXTENSION | |
| import UIKit | |
| extension UITextField { | |
| func underlined(){ | |
| let border = CALayer() |
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
| Source: BorgGreen | |
| 01. Create a new class... | |
| import UIKit | |
| class BaseViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
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
| See: https://stackoverflow.com/questions/31232689/how-to-set-cornerradius-for-only-bottom-left-bottom-right-and-top-left-corner-te/41217791#41217791 | |
| Source: CurvedView | |
| EXTENSION: | |
| import UIKit | |
| extension UIView { | |
| func roundCorners(_ corners:UIRectCorner, radius: 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
| See: https://stackoverflow.com/questions/39624675/add-shadow-on-uiview-using-swift-3 | |
| Source:ViewShadow | |
| Here is the extension with two functions of the same name, one with, the other without parameters. | |
| import UIKit | |
| extension UIView { | |