Tag: UIImageView

  • Code Snippet: Creating a custom ImagePickerViewController, like Instagram

    The standard iOS UIImagePickerViewController is a great way for beginners to get started to accessing the camera and photo library. However, it isn’t used by any of the major photo sharing apps, they all have custom ImagePickers. It is possible to create your own ImagePickerViewController and improve the aesthetics of your photo application. It will improve the engagement levels of your app as a well done ImagePickerViewController can be much more user-friendly and painless than the default UIImagePickerViewController. I have created an ImagePicker that you can use.

    Code Snippet:

    The first screen is the custom ImagePicker. The ImagePicker gives the user the ability to select images from their photo album.

    Simulator Screen Shot - iPhone 8 Plus - 2018-04-21 at 23.54.56

    On this screen, there is also a filter button that will take you to a second screen where you can apply filters to the original image.

    Simulator Screen Shot - iPhone 8 Plus - 2018-04-21 at 23.55.14

    The source code for the finished ImagePickerViewController example project is available here:

    https://github.com/rtking1993/RTKImagePickerViewController

     

  • Tutorial: Implementing UIInterpolating MotionEffect

    This is quite a neat effect that you can add to any of your views on your app. Essentially as you move your phone, the accelerometers inside predict the orientation changes of the phone and provide this movement to your view. It is a great trick to help bring attention to prominent views or images in your app. By creating a small extension on the UIView class you will be able to add this effect to any view with one line of code.

    Tutorial

    First of all, you want to set up a single view application template. Then create a fixed size UIView to contain your main UIImageView. It is important that the clip to bounds attribute for the UIView is set to true and the UIImageView is constrained to be larger than the UIView.

    Screen Shot 2018-01-28 at 8.17.12 AM

    Here is the extension that you will need to add to your project that you can use on any UIView or subclass of UIView.

    https://gist.github.com/rtking1993/e0692e99f0dde15b3cbb32eee0ef8ca0

    Then we want to connect our UIImageView to an outlet and implement the motion effect in the viewDidLoad method.

    https://gist.github.com/rtking1993/2e31ae78464b0aa2a8b54f26c9cda06c

    Adjusting the intensity will change the severity of the effect, reducing the intensity will make the effect less pronounced while increasing the intensity will raise the sensitivity. Be careful of setting the intensity too high, as it could leave your users feeling a bit nauseous!

    Here is the full source code for the project:

    https://github.com/rtking1993/UIImagePickerViewController