zoukankan      html  css  js  c++  java
  • 利用POPAnimatableProperty属性来实现动画倒计时

    POPAnimatableProperty *prop = [POPAnimatableProperty propertyWithName:@"countdown" initializer:^(POPMutableAnimatableProperty *prop) {
            
            prop.writeBlock = ^(id obj,const CGFloat values[])
            {
                
                NSLog(@"%d",(int)values[0]);
                NSString *timestring = [NSString stringWithFormat:@"%02d:%02d:%02d",(int)values[0]/60,(int)values[0]%60,(int)(values[0]*100)%100];
                _lblTest.attributedText = [self formatterTime:timestring];
            };
        }];
        POPBasicAnimation *anBasic = [POPBasicAnimation linearAnimation];   //秒表当然必须是线性的时间函数
        anBasic.property = prop;    //自定义属性
        anBasic.fromValue = @(1*60);   //从0开始
        anBasic.toValue = @(0);  //180秒
        anBasic.duration = 1*60;    //持续3分钟
        anBasic.beginTime = CACurrentMediaTime();    //延迟1秒开始
        [_lblTest pop_addAnimation:anBasic forKey:@"countdown"];
        
    
    }
    - (NSMutableAttributedString *)formatterTime:(NSString *)currentString
    {
    
        NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc]initWithString:currentString];
        for (NSInteger i = 0; i<3; i++)
        {
            [attribute addAttributes:@{
                                       NSBackgroundColorAttributeName:[UIColor redColor],
                                       NSForegroundColorAttributeName:[UIColor whiteColor],
                                     
                                       }
                               range:NSMakeRange(3*i, 2)];
        }
        return  attribute;
    }
    @end

  • 相关阅读:
    简单数学问题
    MFC 注册表编程
    Windows多线程端口扫描
    MFC Socket双向通信
    凯撒加密
    单片机滤波
    大数素性检验
    大数加法乘法
    Unsafe Code
    委托
  • 原文地址:https://www.cnblogs.com/thbbsky/p/4835914.html
Copyright © 2011-2022 走看看