ios 圆UICircularSlider UIView+Animation 几个简单的动画

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{

    

    NSLog(@"____%@",change);

    

    [selfanimationForNumber:[[change valueForKey:@"old"] intValue] newValue:[[change valueForKey:@"new"] intValue]];

}

 

- (void)animationForNumber:(int)oldValue newValue:(int)newValue{

    

    int oldNum2 = (oldValue / 10) % 10;

    int newNum1 = newValue % 10;

    int newNum2 = (newValue / 10) % 10;

    

    if (newValue > oldValue || newValue < oldValue) {

        NSString *direction = newValue > oldValue ? kCATransitionFromTop : kCATransitionFromBottom;

        self.labelSecondNumber.text = [NSString stringWithFormat:@"%d",newNum1];

        [UIViewanimationPush:self.labelSecondNumberdirection:direction duration:0.0];

        if (oldNum2 != newNum2) {

            self.labelFirstNumber.text = [NSString stringWithFormat:@"%d",newNum2];

            [UIView animationPush:self.labelFirstNumber direction:direction duration:0.0];

//            [UIView animationFlip:self.labelFirstNumber direction:direction]; //这里是不同的动画效果。

        }

    }

}

- (void)viewDidLoad

{

    [superviewDidLoad];

    

    self.view.backgroundColor = [UIColorcolorWithRed:38.0/255.0green:38.0/255.0blue:40.0/255.0alpha:1];

    self.date.textColor = [UIColorcolorWithRed:92.0/255.0green:98.0/255.0blue:101.0/255.0alpha:1];

[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(countDown:) name:@"countDown"object:nil];

    

    [self.circularSlideraddTarget:selfaction:@selector(updateProgress:) forControlEvents:UIControlEventValueChanged];

[self.circularSlidersetMinimumValue:0];

[self.circularSlidersetMaximumValue:360];

    if (mIsiP5) {

        self.statusView.frame = (CGRect){120,170,80,18};

    }

}

    

- (IBAction)updateProgress:(UISlider *)sender {

 

    int value = (75 * (sender.value/360));

    

    NSLog(@"_______%d",value);

    

[self.circularSlider setValue:sender.value];

    

    [self.numberView setValue:value];

    

}

猜你喜欢

转载自zhangmingwei.iteye.com/blog/1948108