RHDisplayLinkStepper 1.0.0

RHDisplayLinkStepper 1.0.0

测试已测试
语言 Obj-CObjective C
许可证 BSD
发布最新发布2014年12月

Richard Heard 维护。



  • Richard Heard

一个基于 CADisplayLink 的自定义值步进器,非常适合执行复杂动画或在不同时间段触发代理回调。

概述

例如,UIScrollView可以用此类调用scrollViewDidScroll:,因为它在滚动到新的内容偏移量时动画处理。目前它只支持线性时间,但可以很容易地扩展来进行更复杂的缓冲。

接口

typedef void (^RHDisplayLinkStepperProgressBlock)(CGFloat progress);
typedef void (^RHDisplayLinkStepperCompletionBlock)(BOOL finished);

@interface RHDisplayLinkStepper : NSObject

@property (nonatomic, readonly) CADisplayLink *displayLink;
@property (nonatomic, readonly) BOOL running;

//forward (0.0f -> 1.0f)
-(void)stepWithDuration:(NSTimeInterval)duration progress:(RHDisplayLinkStepperProgressBlock)progressBlock;
-(void)stepWithDuration:(NSTimeInterval)duration progress:(RHDisplayLinkStepperProgressBlock)progressBlock completion:(RHDisplayLinkStepperCompletionBlock)completionBlock;

//reverse (1.0f -> 0.0f)
-(void)reverseStepWithDuration:(NSTimeInterval)duration progress:(RHDisplayLinkStepperProgressBlock)progressBlock;
-(void)reverseStepWithDuration:(NSTimeInterval)duration progress:(RHDisplayLinkStepperProgressBlock)progressBlock completion:(RHDisplayLinkStepperCompletionBlock)completionBlock;

//custom (variable -> variable)
-(void)stepFrom:(CGFloat)from to:(CGFloat)to withDuration:(NSTimeInterval)duration progress:(RHDisplayLinkStepperProgressBlock)progressBlock;
-(void)stepFrom:(CGFloat)from to:(CGFloat)to withDuration:(NSTimeInterval)duration progress:(RHDisplayLinkStepperProgressBlock)progressBlock completion:(RHDisplayLinkStepperCompletionBlock)completionBlock;

//cancel if currently stepping, calls completion block if set.
-(void)cancel;

@end

许可证

在修改的 BSD 许可证下发布。 (需要归属)

RHDisplayLinkStepper

Copyright (c) 2013 Richard Heard. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

iOS 版本支持

此代码在 5.0+ 上运行,并已经过测试。

请随时提交问题,任何在您看来工作不正常或者可以进行改进的地方。

感谢

如果觉得这个项目有用,下次见到我的时候请买杯啤酒,或者找我的愿望清单上找到点什么。