代码库> 视图动画> 可以滚动的button
可以滚动的button
关注
查看次数:1875 下载次数:270
上传时间:2015-09-26 大小:31 B


-(void)start{
    [self.layer removeAllAnimations];
    // Set the index to 0 on starting
    currentIndex = 0;
    _isRuned = YES;
    // Set running
    _running = YES;
    
    //Start the animation
    [self animateCurrentTickerString];
}
-(void)pause{
    // Check if running
    if (_running) {
        // Pause the layer
        [self pauseLayer:self.layer];
        
        _running = NO;
    }
}

-(void)resume{
    // Check not running
    if (!_running) {
        //Resume the layer
        [self resumeLayer:self.layer];
        
        _running = YES;
    }
}

#pragma  mark -UIView layer animaion utiltiles
-(void)pauseLayer:(CALayer *)layer{
    CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
    layer.speed = 0.0;
    layer.timeOffset = pausedTime;
}
-(void)resumeLayer:(CALayer *)layer{
    CFTimeInterval pausedTime = [layer timeOffset];
    layer.speed = 1.0;
    layer.timeOffset = 0.0;
    layer.beginTime = 0.0;
    CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
    layer.beginTime = timeSincePause;
}





收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0
提示
sina weixin mail 回到顶部