https://github.com/kornerr/ios-collapse-expand
Sample iOS application to implement collapse/expand animation
https://github.com/kornerr/ios-collapse-expand
ios ios-application swift
Last synced: 11 days ago
JSON representation
Sample iOS application to implement collapse/expand animation
- Host: GitHub
- URL: https://github.com/kornerr/ios-collapse-expand
- Owner: kornerr
- Created: 2018-07-18T11:19:16.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-20T14:51:39.000Z (almost 8 years ago)
- Last Synced: 2025-07-04T13:23:29.259Z (12 months ago)
- Topics: ios, ios-application, swift
- Language: Swift
- Size: 695 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Overview
This is a sample iOS application to implement collapse / expansion animation.
# Preview
This is what the app looks like:
![Preview][preview]
# Collapse / expansion animation
The are several entities at play:
* `LayoutReportingView`
* a simple `UIView` derivative to report when `UIView` instance gets `layoutSubviews()` call
* `MainVC.storyboard`
* provides `DetailsView`, which is `LayoutReportingView`
* constraints `DetailsView` to the collapsed state with a fixed height constraint
* height: 100
* priority: 750
* expands `DetailsView` to the top of the superview
* priority: 1000
* `CollapseExpansionController`
* accepts height range available for expansion
* installs `UIPanGestureRecognizer` into tracked view
* reports new `height` values each pan gesture
* reports final `height` value once pan gesture is finished
* `AppDelegate`
* creates `CollapseExpansionController`
* only does so once height range of `DetailsView` becomes available
* provides `DetailsView` as tracked view
* sets `DetailsView` height to the `height` while panning (`heightChanged` callback)
* animates `DetailsView` height to the `height` after panning (`completeHeightChange` callback)
**Note**: [XcodeGen][xcodegen] was used to generate Xcode project
[preview]: preview.gif
[xcodegen]: https://github.com/yonaskolb/XcodeGen