# ShapeAnimation-Swift
Vector animation framework in Swift based on [SwiftGraphics](https://github.com/schwa/SwiftGraphics) for iOS 8.
With ShapeAnimation you can easily create various animations with a nice Swift based syntax.
[![Travis][travis_img]][travis]
[travis]: https://travis-ci.org/rhcad/ShapeAnimation-Swift
[travis_img]: https://travis-ci.org/rhcad/ShapeAnimation-Swift.svg?branch=master
The current development happens on the [develop][develop] branch. Code is merged back on master branch infrequently.
SVG animation development with [SVGKit](https://github.com/SVGKit/SVGKit) happens on the [SVG][svg_branch] branch.
[develop]: https://github.com/rhcad/ShapeAnimation-Swift/tree/develop
[svg_branch]: https://github.com/rhcad/ShapeAnimation-Swift/tree/SVG
## What's included
* ShapeView class which contains vector shape layers.
* Helper functions to add image, text, circle, regular polygon, lines and other shapes.
* Support gradient fill with animation.
* Enumerate, hit-test or find layers.
* Animation extension functions of CALayer.
* opacityAnimation, flashAnimation, backColorAnimation
* scaleAnimation, tapAnimation, transformAnimation
* rotate360Degrees, rotationAnimation
* shakeAnimation, moveAnimation, moveOnPathAnimation
* slideToRight, slideAnimation, flipHorizontally, flipVertically
* Layer dragging: constrainCenterToSuperview, bringOnScreen
* Animation extension functions of CAShapeLayer.
* strokeStartAnimation, strokeEndAnimation, lineWidthAnimation
* strokeColorAnimation, fillColorAnimation, dashPhaseAnimation
* switchPathAnimation
* Group animation and cascaded animation.
* animationGroup for the same layer
* applyAnimations for multiple layers
* Use the block-based function in apply() to play cascaded animations.
* Pause, resume or stop animations.
* Animations with customized properties
* Use AnimationLayer class to draw customized animations.
* Animation with sliders example: [EllipseViewController.swift](ShapeAnimation_UITest/EllipseViewController.swift)
![Stroke Lines](Documentation/strokelines.gif)
![Move on Path](Documentation/moveonpath.gif)
![Radar Circles](Documentation/radar.gif)
![Rotate Polygons](Documentation/rotate_polygons.gif)
![Jumping Ball](Documentation/jumpball.gif)
![Animation with Sliders](Documentation/ellipse_slider.gif)
![Drag Layers](Documentation/drag.gif)
## Usage
Please see the examples in [MasterViewController.swift](ShapeAnimation_UITest/MasterViewController.swift).
``` Swift
let layer1 = self.addLinesLayer(view, points:[(10.0,20.0),(150.0,40.0),(120.0,320.0)])
layer1.strokeEndAnimation().apply() {
layer1.shakeAnimation().apply()
}
let la2 = self.addLinesLayer(view, points:points2, color: UIColor.blueColor())
lla2.scaleAnimation(from:1, to:1.1, repeatCount:3).apply(duration:0.3)
let la3 = self.addLinesLayer(view, points:points3, color: UIColor.greenColor())
la3.flashAnimation(repeatCount:6).apply()
let la4 = self.addLinesLayer(view, points:[(10.0,20.0), (150.0,40.0), (120.0,120.0)])
let a1 = la4.moveOnPathAnimation(path).setDuration(1.6)
let a2 = la4.rotate360Degrees().setRepeatCount(2)
animationGroup([a1, a2]).autoreverses().apply()
```
## Help Wanted
All of this code is very much a _*work in progress*_. I'm adding and changing functionality as needed.
Your help wanted. Please fork this project and submit pull requests or [issues][issues].
[issues]: https://github.com/rhcad/ShapeAnimation-Swift/issues
Contributions are always welcome in the following areas:
* Header doc comments explaining what the functions do
* Useful animation template or application examples
* Fix issues about animation, Swift usage rules or translations
## License
ShapeAnimation-Swift is released under a BSD License. See LICENSE file for details.
## FAQ
* Could not build Objective-C module 'ShapeAnimation':
- Quit Xcode and delete the sub folders in ~/Library/Developer/Xcode/DerivedData/.
Swift 中的矢量动画框架
需积分: 0 178 浏览量
更新于2024-03-15
收藏 2.61MB ZIP 举报
动画-Swift
Swift 中的矢量动画框架,基于iOS 8 的SwiftGraphics 。
使用 ShapeAnimation,您可以使用基于 Swift 的良好语法轻松创建各种动画。
当前的开发发生在开发分支上。代码很少合并回主分支。
使用SVGKit进行 SVG 动画开发发生在SVG分支上。
包含什么
ShapeView 类包含矢量形状图层。
添加图像、文本、圆形、正多边形、直线和其他形状的辅助功能。
支持动画渐变填充。
枚举、命中测试或查找图层。
CALayer的动画扩展功能。
opacityAnimation、flashAnimation、backColorAnimation
缩放动画、点击动画、变换动画
旋转360度,旋转动画
shakeAnimation、moveAnimation、moveOnPathAnimation
SlideToRight、slideAnimation、水平翻转、垂直翻转
图层拖动:constrainCenterToSuperview、bringOnScreen
前网易架构师-高司机
- 粉丝: 9913
- 资源: 1230
最新资源
- py-apple-controller-四足机器人
- py-apple-bldc-quadruped-robot-四足机器人
- 四足机器人-四足机器人
- asm-西电微机原理实验
- 四足机器人行走机制设计与应用解析
- 探索POINTS 1.5视觉思考模型:开启高效思考之门
- 支持 DELPHI 12.2的RXLIB 控件
- game_patch_1.29.13.13020.pak
- 4S店车辆管理系统.zip
- J2EE在在线项目管理与任务分配中的应用_411v2rh8_226-wx.zip
- “课件通”中小学教学课件共享平台.zip
- Java Web的租房管理系统(编号:22787207).zip
- Java大学生创新能力培养平台的设计与实现(编号:49116136).zip
- JavaWeb图书管理系统(编号:29027118)(1).zip
- springboot4S店车辆管理系统 LW PPT.zip
- spingboot茶文化推广系统(编号:3018432).zip