@IBAction func pickAnImageFromAlbum(_ sender: Any){ let imagePicker = UIImagePickerController() imagePicker.delegate = self present(imagePicker, animated: true, completion: nil) } @IBAction func pickAnImageFromCamera(_ sender: Any){ let imagePicker = UIImagePickerController() imagePicker.delegate = self present(imagePicker, animated: true, completion: nil) } @IBAction func pickAnImageFromAlbum(_ sender: Any){ let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .photoLibrary present(imagePicker, animated: true, completion: nil) } cameraButton.isEnabled = UIImagePickerController.isSourceTypeAvailable(.camera)
let memeTextAttributes:[String:Any] = [ NSStrokeColorAttributeName: NSForegroundColorAttributeName: NSFontAttributeName: UIFont(name: "HelveticaNeue-CondenseBlack", size: 40)!, NSStrokeWidthAttributeName: ]
override func viewWillAppear(_ animated: Bool){ super.viewWillAppear(animated) subscribeTokeyboardNotifications() } override func viewWillDisappear(_ animated: Bool){ super.viewWillDisappear(animated) unsubscribeFromKeyboardNotifications() } func subscribeToKeyboardNotifications(){ NotificationCenter.default.addObserver(self, selector: #selector(keboardWillShow(_:)), name: .UIKey) } func keyboardWillShow(_ notification:Notification){ view.frame.origin.y -= getKeyboardHeight(notification) } func getKeyboardHeight(_ notification:Notification) -> CGFloat{ let userInfo = notification.userInfo let keyboardSize = userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue return keyboardSize.cgRectValue.height }