Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moo611/ios-zoomingtransition
A library to make zooming transition easier
https://github.com/moo611/ios-zoomingtransition
ios-animation ios-swift ios-transition swift
Last synced: 4 months ago
JSON representation
A library to make zooming transition easier
- Host: GitHub
- URL: https://github.com/moo611/ios-zoomingtransition
- Owner: moo611
- License: mit
- Created: 2021-02-04T13:03:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-06T05:22:29.000Z (about 4 years ago)
- Last Synced: 2024-10-11T06:11:22.303Z (4 months ago)
- Topics: ios-animation, ios-swift, ios-transition, swift
- Language: Swift
- Homepage:
- Size: 6.69 MB
- Stars: 30
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ZoomingTransition
[](https://travis-ci.org/[email protected]/ZoomingTransition)
[](https://cocoapods.org/pods/ZoomingTransition)
[](https://cocoapods.org/pods/ZoomingTransition)
[](https://cocoapods.org/pods/ZoomingTransition)## Example

## Requirements
ios 10.0 , swift 5.0
## How to use#### 1. Pod install
```ruby
pod 'ZoomingTransition'
```
#### 2. To make your viewcontroller as a "PushVC", just extends ZoomPushVC ,and implement ZoomTransitionAnimatorDelegate
```swiftclass MyPushVC : ZoomPushVC,ZoomTransitionAnimatorDelegate{
var lastSelectedIndexPath: IndexPath? = nil
//your own code...
func transitionWillStart() {
guard let lastSelected = self.lastSelectedIndexPath else { return }
self.collectionView.cellForItem(at: lastSelected)?.isHidden = true
}func transitionDidEnd() {
guard let lastSelected = self.lastSelectedIndexPath else { return }
self.collectionView.cellForItem(at: lastSelected)?.isHidden = false
}func referenceImage() -> UIImage? {
guard
let lastSelected = self.lastSelectedIndexPath,
let cell = self.collectionView.cellForItem(at: lastSelected) as? CustomCell
else {
return nil
}return cell.imageView.image
}func imageFrame() -> CGRect? {
guard
let lastSelected = self.lastSelectedIndexPath,
let cell = self.collectionView.cellForItem(at: lastSelected) as? CustomCell
else {
return nil
}
return FrameHelper.getTargerFrame(originalView: cell.imageView, targetView: self.view)}
}```
#### 3. Record the lastSelectedIndexPath when click the item of collectionview```swift
class MyPushVC : ZoomPushVC,ZoomTransitionAnimatorDelegate{
//with the code above ...
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.lastSelectedIndexPath = indexPath
let vc = PreviewVC()
vc.image = self.slices[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
}}
```
#### 4. To make your viewcontroller as a "PopVC", just implement ZoomTransitionAnimatorDelegate```swift
class PreviewVC: UIViewController,ZoomTransitionAnimatorDelegate{//...your own code
//when back button clicked
@objc func close(){
self.navigationController?.popViewController(animated: true)
}func transitionWillStart() {
// self.imageView.isHidden = true
self.view.alpha = 0
}func transitionDidEnd() {
// self.imageView.isHidden = true
self.view.alpha = 1
}func referenceImage() -> UIImage? {
return FrameHelper.getScreenshot(with: self.view)
}func imageFrame() -> CGRect? {
return self.view.frame
}
}```
That's it ! Then you will see the fantastic zooming transition :)
## AuthorDesong
## License
ZoomingTransition is available under the MIT license. See the LICENSE file for more info.