Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shima11/interactivezoomdriver
Image zoomable like Instagram.
https://github.com/shima11/interactivezoomdriver
carthage cocoapods driver imageview instagram interactive ios swift zoom-images zoomable
Last synced: about 1 month ago
JSON representation
Image zoomable like Instagram.
- Host: GitHub
- URL: https://github.com/shima11/interactivezoomdriver
- Owner: shima11
- License: mit
- Created: 2018-04-16T05:56:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T14:19:45.000Z (5 months ago)
- Last Synced: 2024-12-19T04:06:50.356Z (about 2 months ago)
- Topics: carthage, cocoapods, driver, imageview, instagram, interactive, ios, swift, zoom-images, zoomable
- Language: Swift
- Homepage:
- Size: 17 MB
- Stars: 44
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# InteractiveZoomDriver
This repo is view to zoomable by pinch gesture.## Overview
![](demo.gif)
## Installation
### Swift Package Manager
For installing with SPM, add it to your `Package.swift`.
```swift
dependencies: [
.package(url: "https://github.com/shima11/InteractiveZoomDriver.git", from: "1.2.5"))
]
```### Carthage
For installing with Carthage, add it to your `Cartfile`.
```
github "shima11/InteractiveZoomDriver"
```### CocoaPods
For installing with CocoaPods, add it to your `Podfile`.
```
pod 'InteractiveZoomDriver'
```## Usage
```
import InteractiveZoomDriverlet zoomView = UIImageView() // UIView or SubClass of UIView
zoomView.isUserInteractionEnabled = true
```### Case1: driver
Add zoom function to target UIView.`gestureTargetView`: added tap and pan gesture.
`sourceView`: source view.
`targetViewFactory`: Transformed View during zooming.
`shouldZoomTransform`: Delegate to the outside whether zooming is possible.```
let driver = InteractiveZoomDriver(
gestureTargetView: imageView2,
sourceView: imageView2,
targetViewFactory: { (fromImageView: UIImageView) -> UIView in
let view = UIImageView()
view.image = fromImageView.image
view.clipsToBounds = fromImageView.clipsToBounds
view.contentMode = fromImageView.contentMode
return view
},
shouldZoomTransform: {(sourceView: UIImageView) -> Bool in
if sourceView.image == nil {
return false
}
return true
}
)
```
This is also no problem.
`InteractiveZoomView.clone` and `InteractiveZoomView.shouldZoomTransform` is default implementation of protocol extension.
`InteractiveZoomView` corresponds to `UIImageView` only.
To support other than `UIImageView`, add an implementation in extension.```
let driver = InteractiveZoomDriver(
gestureTargetView: zoomView,
sourceView: zoomView,
targetViewFactory: InteractiveZoomView.clone,
shouldZoomTransform: InteractiveZoomView.shouldZoomTransform
)
```### Case2: overlay view
InteractiveZoomView is able to only UIImageView now.
If you want to use custom UIView, you need to create extension of InteractiveZoomView with reference to InteractiveZoomView.```
let overlayZoomView = InteractiveZoomView(
sourceView: zoomView
)
view.addSubView(overlayZoomView)
```