This library facilitates the use of tilt to preview images. So for images that extend beyond the space allocated to them, a simple tilt of the device will let you preview the rest of the sections of the image. Special thanks to team lorempixel for their super awesome service of providing great placeholder images.
Add this line to your application's Gemfile:
gem 'motion-gyro-image-controller'
And then execute:
bundle
A sample app is included for reference. To get it up and running, simply clone the
repository and run rake
or rake device
depending on whether you want
to preview it in the simulator or device.
But here is how you can go about using this library:
-
Initialize the image controller as follows:
image_controller = GyroDrivenImageViewController.new ```
-
Set up the origin and size of the view using the following method:
image_controller.set_up_view(x_origin, y_origin, width, height) ```
-
Set the control variables for sensitivity, update frequency and image motion rate:
image_controller.update_interval = update_interval # sample value: 1.0/120.0 image_controller.motion_rate = image_motion_rate # sample value: PI/180.0 image_controller.shake_threshold = shake_sensitivity # sample value: 0.1 ```
-
In case you intend to use this in an image gallery, you may need to assign each image an index. We have provided an index value for each controller:
image_controller.index = index ```
-
To set the actual image, there is a method that accepts an instance of
UIImage
. The sample app provides an example of how to use thesetImageWithURL
method to pull images from a server and use them. The syntax for the method to set the image is:
image_controller.set_image image ```
See the CONTRIBUTING document. Thank you, contributors!
iOS (RubyMotion) Image Controller with Tilt Control is Copyright (c) 2016 Multunus Software Pvt. Ltd. It is free software, and may be redistributed under the terms specified in the LICENSE file.
iOS (RubyMotion) Image Controller with Tilt Control is maintained and funded by Multunus Software Pvt. Ltd. The names and logos for Multunus are trademarks of Multunus Software Pvt. Ltd.
We love open source software! See our other projects or hire us to help build your product.