Accessing photos in iOS swift 3

let imagePicker = UIImagePickerController()
  • A sourceType of camera provides a user interface for taking a new picture or movie (on devices that support media capture).
  • A sourceType of photoLibrary or savedPhotosAlbum provides a user interface for choosing among saved pictures and movies.
public enum UIImagePickerControllerSourceType : Int {case photoLibrarycase cameracase savedPhotosAlbum}
imagePicker.mediaTypes = [kUTTypeMovie as String] // the default value is kUTTypeImage ..
imagePicker.mediaTypes = UIImagePickerController.availableMediaTypes(!

Getting the image form the info dictionary

UIImagePickerController give a dictionary with information about the selected media. You can find the UIImageinstance representing the selected image on the UIImagePickerControllerOriginalImage key. The ifo dictionary may contain:

source code

Asking for permission

The app must ask for permission from the user before accessing the camera/ the saved photos.The app should display a message to the user explaining why it needs the camera or photo library access. You can set this message by setting the NSCameraUsageDescription and NSPhotoLibraryUsageDescription key in the Info.plist file of your app.

plist file
permission prompt

Custom overlays for UIImagePickerController

For adding a custom overlay UI for your UIImagePickerController, set theUIImagePickerController's showCameraControls property to NO. Then you should set the cameraOverlayView property of UIImagePickerController.

If you enjoyed reading this post, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!



iOS and tvOS developer, dreamer, photographer 🤨

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


iOS and tvOS developer, dreamer, photographer 🤨