https://github.com/yuriiik/isvimagescrollview
Image preview component with zoom, scroll and rotation support
https://github.com/yuriiik/isvimagescrollview
image-preview ios preview uiscrollview
Last synced: about 1 year ago
JSON representation
Image preview component with zoom, scroll and rotation support
- Host: GitHub
- URL: https://github.com/yuriiik/isvimagescrollview
- Owner: yuriiik
- License: mit
- Created: 2017-10-23T12:31:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-01-17T14:53:36.000Z (over 4 years ago)
- Last Synced: 2025-03-27T14:11:10.973Z (about 1 year ago)
- Topics: image-preview, ios, preview, uiscrollview
- Language: Swift
- Homepage:
- Size: 3.37 MB
- Stars: 34
- Watchers: 3
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ISVImageScrollView
[](https://travis-ci.org/kupratsevich@gmail.com/ISVImageScrollView)
[](http://cocoapods.org/pods/ISVImageScrollView)
[](http://cocoapods.org/pods/ISVImageScrollView)
[](http://cocoapods.org/pods/ISVImageScrollView)
A subclass of the UIScrollView tweaked for image preview with zooming, scrolling and rotation support.
## Overview
When you need to incorporate an image preview into your application, usually you start with the UIScrollView and then spend hours tweaking it to get functionality similar to the default Photos app. This control provides you out-of-the-box functionality to zoom, scroll and rotate an UIImageView attached to it.
## Features
* Pinch to zoom and scroll
* Tap to zoom
* Scale image when scroll view bounds change, e.g. after rotation
* Set appropriate content offset after rotation to make sure visible content remains the same
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
* Tested on iOS 9.3 and higher, but should work on iOS 8.x as well
## Installation
### CocoaPods
ISVImageScrollView is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile:
```ruby
pod 'ISVImageScrollView'
```
### Swift Package Manager
ISVImageScrollView is also available via the Swift Package Manager.
## Usage
ISVImageScrollView is very easy to use.
1. Create a __UIImageView__ instance and assign it an image.
2. Create an __ISVImageScrollView__ instance (either programmatically or via the Storyboard/XIB) and assign the created UIImageView object to its __imageView__ property.
3. Don't forget to set __maximumZoomScale__ and __delegate__ properties of the ISVImageScrollView instance.
4. Finally in delegate class implement __viewForZoomingInScrollView:__ method and return the UIImageView object created in step 1.
```swift
let image = UIImage(named: "Photo.jpg")
self.imageView = UIImageView(image: image)
self.imageScrollView.imageView = self.imageView
self.imageScrollView.maximumZoomScale = 4.0
self.imageScrollView.delegate = self
```
```swift
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.imageView
}
```
## Author
Yurii Kupratsevych
kupratsevich@gmail.com
## License
ISVImageScrollView is available under the MIT license. See the LICENSE file for more info.