在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:willowtreeapps/spruce-ios开源软件地址:https://github.com/willowtreeapps/spruce-ios开源编程语言:Swift 95.1%开源软件介绍:Android)Spruce iOS Animation Library (andWhat is it?Spruce is a lightweight animation library that helps choreograph the animations on the screen. With so many different animation libraries out there, developers need to make sure that each view is animating at the appropriate time. Spruce can help designers request complex multi-view animations and not have the developers cringe at the prototype. Here is a quick example of how you can Spruce up your screens! Installation InstructionsTo make everything super easy, we currently support both CocoaPods and Carthage. If you want to just do everything yourself without a package manager, checkout our releases page and download the pre-built frameworks there or you can download the exact source from this Github project. CocoaPodsAdd the following to your
CarthageAdd the following to your
Getting StartedSpruce is entirely written in Basic UsageSpruce comes packed with Preparing for AnimationIf you want a view to fade in, then you need to make sure that it is already faded out. To do that, we need to yourView.spruce.prepare(ourAnimations) This Running the AnimationUse the following command to run a basic animation on your view. yourView.spruce.animate(ourAnimations) Checkout the documentation for more functions and how to better use the Using a SortFunctionLuckily, Spruce comes with around 8 let sortFunction = LinearSortFunction(direction: .topToBottom, interObjectDelay: 0.1) In this example we have created a yourView.spruce.animate([.fadeIn, .expand(.slightly)], sortFunction: sortFunction) Definitely play around with the stock Using a Custom AnimationThough Spruce comes with a ton of stock animations, sometimes it is easier to make your own. We definitely encourage customization and Spruce is ready for it! Let's say you want to transform and animate a let prepareHandler = { view in
view.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
} The let changeFunction = { view in
view.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
} In let animation = StockAnimation.custom(prepareFunction: prepareHandler, animateFunction: changeFunction) Once we have the animation all we need to do is pass that animation into Spruce and let the animation begin! yourView.spruce.animate([animation]) Basic ConceptsAnimationsGiven a change function that specifies how the views are modified, you are able to specify any type of animation that you would like. Feel free to implement the The Animation ProtocolThe protocol has one function and a variable that need to be implemented in your class. First is the var changeFunction: ChangeFunction? { get set }
func animate(delay: TimeInterval, view: UIView, completion: CompletionHandler?) Standard AnimationThe Spring AnimationThe Sort FunctionsWith all different types of animations, especially those dealing with subviews, we have to consider a way in which we want to animate them. Some views can have 0 subviews while others may have hundreds. To handle this, we have the notion of a The SortFunction ProtocolA very simple protocol that requires classes to implement the following function func timeOffsets(view: UIView, recursiveDepth: Int) -> [TimedView] What the above function needs to do is take in a Stock Sort FunctionsTo make sure that developers can use Spruce out of the box, we included about 8 stock
Check out the docs here for more information Stock AnimationsTo make everybody's lives easier, the stock animations perform the basic
Experiment which ones work for you! If you think of anymore feel free to add them to the library yourself! Example AppUse the example app to find the right Also included in the sample app are the implementations for the two extensibility tests shown above that demonstrate how to use Spruce with a Contributing to SpruceContributions are more than welcome! Please see the Contributing Guidelines and be mindful of our Code of Conduct. Issues or Future IdeasIf part of Spruce is not working correctly be sure to file a Github issue. In the issue provide as many details as possible. This could include example code or the exact steps that you did so that everyone can reproduce the issue. Sample projects are always the best way :). This makes it easy for our developers or someone from the open-source community to start working! If you have a feature idea submit an issue with a feature request or submit a pull request and we will work with you to merge it in! About WillowTree!We build apps, responsive sites, bots—any digital product that lives on a screen—for the world’s leading companies. Our elite teams challenge themselves to build extraordinary experiences by bridging the latest strategy and design thinking with enterprise-grade software development. Interested in working on more unique projects like Spruce? Check out our careers page. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论