Gemini 是一个采用Swift编写用于iOS的丰富滚动动画框架

网友投稿 874 2022-11-03

Gemini 是一个采用Swift编写用于iOS的丰富滚动动画框架

Gemini 是一个采用Swift编写用于iOS的丰富滚动动画框架

Overview

What is the Gemini?

Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which is a subclass of UICollectionView.

It enables you to make multiple animation which has various and customizable properties, and moreover can create your own custom scroll animation.

Gemini also provides a fluent interface based on method chaining. you can use this intuitively and simply.

collectionView.gemini .circleRotationAnimation() .radius(400) .rotateDirection(.clockwise)

Features

Rich animation with scrolling Easily usable Highly customizable Several types of animations and properties Supports vertical and horizontal flow layout Supports easing function Supports Swift5.0 Fluent interfaces based on method chaining Compatible with Carthage Compatible with CocoaPods Example project with lots of stock animations And More...

Contents

Animation Types and propertiesUsageRequirementsInstallationAuthor

Animation Types and properties

The following animation types are available. See sample code here for details.

CubeCircle Rotation You can configure direction of rotation using the CircleRotationDirection3D vector rotation Each rotation types provide multiple rotation effect Roll RotationPitch RotationYaw Rotation ScaleCustom You can create your own custom scroll animation using multiple properties, rotation, scale, translation, etc.

In addition, you can also customize the following properties for the above animation types.

BackgroundColorCornerRadiusAlphaEasingsShadow Effect

Cube

CircleRotation

3D vector rotation

Available for Roll, Pitch and Yaw animation. These rotation animation are designed based on 3-Dimensional vector. Figure-1 shows direction of rotation based on device.

Figure-1 Pitch, roll, and yaw axes

Reference: Event Handling Guide for UIKit Apps

Roll Rotation

Pitch Rotation

Yaw Rotation

Scale

Custom

There are more sample code at CustomAnimationViewController.swift.

Easing function

Gemini supports various easing functions based on distance of scroll.lineareaseInQuadeaseOutQuadeaseInOutQuadeaseInCubiceaseOutCubiceaseInOutCubiceaseInQuarteaseOutQuarteaseInOutQuarteaseInQuinteaseOutQuinteaseInOutQuinteaseInSineeaseOutSineeaseInOutSineeaseInExpoeaseOutExpoeaseInOutExpoeaseInCirceaseOutCirceaseInOutCirc

Shadow effect

Default value is ShadowEffect.none. Return shadowView in your custom class, which is a subclass of GeminiCell.fadeInnextFadeInpreviousFadeInfadeOutnoneclass CustomCollectionViewCell: GeminiCell { @IBOutlet weak var customShadowView: UIView! override var shadowView: UIView? { return customShadowView }}

Usage

Use Gemini classes Gemini is designed to be easy to use. Use GeminiCollectionView and GeminiCell. These classes is subclass of UICollectionView, UICollectionViewCell.Configure animation Configure animation with fluent interface based on method chaining. You can develop expressive code that enhances readability.Call function for animation Finally, call animateVisibleCells() in scrollViewDidScroll(_:)NOTE: If you want to adapt animation immediately after view is displayed, call animateCell(_:) in collectionView(_:cellForItemAt:) and collectionView(_:willDisplay:forItemAt:).// Import Geminiimport Gemini// Inherite GeminiCellclass CustomCell: GeminiCell { ...}// Conform to UICollectionViewDelegate and UICollectionViewDataSourceclass CustomViewController: UIViewController: UICollectionViewDelegate, UICollectionViewDataSource { // Inherite GeminiCollectionView @IBOutlet weak var collectionView: GeminiCollectionView! ... // Configure animation and properties func configureAnimation() { collectionView.gemini .circleRotationAnimation() .radius(400) .rotateDirection(.clockwise) } // Call animation function func scrollViewDidScroll(_ scrollView: UIScrollView) { collectionView.animateVisibleCells() } func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { if let cell = cell as? GeminiCell { self.collectionView.animateCell(cell) } } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CustomCell", for: indexPath) as! CustomCell self.collectionView.animateCell(cell) return cell }

See Example, for more details.

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Xcode 10.2.1Swift 5.0

Installation

CocoaPods

Gemini is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Gemini"

Carthage

Add the following line to your Cartfile:

github "shoheiyokoyama/Gemini"

Author

Shohei Yokoyama

GitHubFacebookTwitterGmail: shohei.yok0602@gmail.com

License

Gemini is available under the MIT license. See the LICENSE file for more info.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:一个简洁的公司官网主页,使用spring boot作为后台框架.
下一篇:springboot实现配置本地访问端口及路径
相关文章

 发表评论

暂时没有评论,来抢沙发吧~