What about the camera?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@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)
1
2
3
4
5
6
let memeTextAttributes:[String:Any] = [
    NSStrokeColorAttributeName:
    NSForegroundColorAttributeName:
    NSFontAttributeName: UIFont(name: "HelveticaNeue-CondenseBlack", size: 40)!,
    NSStrokeWidthAttributeName:
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
}