• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

View-Animator: ViewAnimator 是一个以简单的方式构建复杂的 iOS UI 布局及动画切换库 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

View-Animator

开源软件地址:

https://gitee.com/mirrors/View-Animator

开源软件介绍:

CocoaPods Carthage Codebeat License

ViewAnimator is a library for building complex iOS UIView animations in an easy way. It provides one line animations for any view included the ones which contain other views like UITableView and UICollectionView with its cells or UIStackView with its arrangedSubviews.

Entire View         UITableView                                  UICollectionView

                

SVG animations inspired by Luke Zhao's project Hero

Complex Layouts

UI created by Messaki, make sure to check out his profile.

Logo and banner created by @cintia_ve

Installation

CocoaPods

ViewAnimator is available through CocoaPods. To installit, simply add the following line to your Podfile:

pod "ViewAnimator"

Manual

Drop the swift files inside of ViewAnimator/Classes into your project.

Carthage

github "marcosgriselli/ViewAnimator"

Usage

ViewAnimator provides a set of UIView extensions to easily add custom animations to your views. From version 2.0.0 there are two ways to use this extension.

Self animating views

Views can animate theirselves calling .animate(animations: [Animation]) that's the most basic usage. Here's the full method that contains many default arguments:

func animate(animations: [Animation],             reversed: Bool = false,             initialAlpha: CGFloat = 0.0,             finalAlpha: CGFloat = 1.0,             delay: Double = 0,             duration: TimeInterval = ViewAnimatorConfig.duration,             usingSpringWithDamping dampingRatio: CGFloat = ViewAnimatorConfig.springDampingRatio,             initialSpringVelocity velocity: CGFloat = ViewAnimatorConfig.initialSpringVelocity,             completion: (() -> Void)? = nil)

Animating multiple views

ViewAnimator follows the UIKit animations API style with a static method UIView.animate(views: [UIView], animations: [Animation]). This makes the library really easy to use and extensible to any kind of view. As the previous example, the method contains a lot of default arguments:

static func animate(views: [UIView],                    animations: [Animation],                    reversed: Bool = false,                    initialAlpha: CGFloat = 0.0,                    finalAlpha: CGFloat = 1.0,                    delay: Double = 0,                    animationInterval: TimeInterval = 0.05,                    duration: TimeInterval = ViewAnimatorConfig.duration,                    usingSpringWithDamping dampingRatio: CGFloat = ViewAnimatorConfig.springDampingRatio,                    initialSpringVelocity velocity: CGFloat = ViewAnimatorConfig.initialSpringVelocity,                    completion: (() -> Void)? = nil)

AnimationType

Direction

Direction provides the axis where the animation should take place and its movement direction.

let animation = AnimationType.from(direction: .top, offset: 30.0)view.animate(animations: [animation])

Zoom

Zoom in and Zoom out animation support.

let animation = AnimationType.zoom(scale: 0.5)view.animate(animations: [animation])

Combined Animations

You can combine conformances of Animation to apply multiple transforms on your animation block.

let fromAnimation = AnimationType.from(direction: .right, offset: 30.0)let zoomAnimation = AnimationType.zoom(scale: 0.2)let rotateAnimation = AnimationType.rotate(angle: CGFloat.pi/6)UIView.animate(views: collectionView.visibleCells,               animations: [zoomAnimation, rotateAnimation],               duration: 0.5)UIView.animate(views: tableView.visibleCells,               animations: [fromAnimation, zoomAnimation],                delay: 0.5)

Animation

Animation protocol provides you the posibility of expanding the animations supported by ViewAnimator with exception of the animateRandom function.

public protocol Animation {    var initialTransform: CGAffineTransform { get }}

UITableView/UICollection extensions

ViewAnimator comes with a set of handy extensions to make your animations in UITableView and UICollectionView a lot simpler. They both have access to cells in a section to animate easily.

They both expose a method visibleCells(in section: Int) that returns an array of UITableViewCell or UICollectionViewCell.

let cells = tableView.visibleCells(in: 1)UIView.animate(views: cells, animations: [rotateAnimation, fadeAnimation])

Mentions

Project Details

Requirements

  • Swift 4.0
  • Xcode 7.0+
  • iOS 8.0+

Contributing

Feel free to collaborate with ideas


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap