forked from BigShow1949/BigShow1949
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
375 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.33 KB
(100%)
...xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
BigShow1949/Classes/Animations/04 - 渐变色和贝塞尔曲线/仿支付宝余额跳动/UILabel+BezierAnimation.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// UILabel+BezierAnimation.h | ||
// Test | ||
// | ||
// Created by senro wang on 15/8/11. | ||
// Copyright (c) 2015年 王燊. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UILabel (BezierAnimation) | ||
|
||
//label 上的数字 从某一个值变化到 另一个值 - (动画) - | ||
|
||
- (void)animationFromnum:(float )fromNum toNum:(float )toNum duration:(float )duration; | ||
|
||
|
||
@end |
105 changes: 105 additions & 0 deletions
105
BigShow1949/Classes/Animations/04 - 渐变色和贝塞尔曲线/仿支付宝余额跳动/UILabel+BezierAnimation.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// | ||
// UILabel+BezierAnimation.m | ||
// Test | ||
// | ||
// Created by senro wang on 15/8/11. | ||
// Copyright (c) 2015年 王燊. All rights reserved. | ||
// | ||
|
||
#import "UILabel+BezierAnimation.h" | ||
#import "WSBezier.h" | ||
|
||
#define KMaxTimes 100 | ||
|
||
|
||
@implementation UILabel (BezierAnimation) | ||
|
||
NSMutableArray *totlePoints; //纪录所有的点。 | ||
|
||
WSBezier *bezier; //通过 改变bezier 函数的参数 (也就是 四个 控制点)可以改变动画的样式 - | ||
|
||
float _duration; // 动画 间隔 | ||
float _fromNum; | ||
float _toNum; | ||
|
||
float _lastTime; //纪录每一个点的 时刻 | ||
|
||
int _index; | ||
|
||
|
||
//- (instancetype)initWithFrame:(CGRect)frame{ | ||
// | ||
// if (self = [super initWithFrame:frame]) { | ||
// | ||
//// [self _initBezier]; | ||
//// [self _cleanVars]; | ||
// } | ||
// | ||
// return self; | ||
//} | ||
|
||
- (void)_cleanVars{ | ||
|
||
_lastTime = 0; | ||
_index = 0; | ||
// self.text = @"0"; | ||
|
||
} | ||
|
||
|
||
//初始化 控制点 | ||
- (void)_initBezier{ | ||
|
||
|
||
bezier = [[WSBezier alloc] init]; | ||
} | ||
|
||
|
||
- (void)animationFromnum:(float)fromNum toNum:(float)toNum duration:(float)duration{ | ||
|
||
[self _cleanVars]; | ||
[self _initBezier]; | ||
|
||
_duration = duration; | ||
_fromNum = fromNum; | ||
_toNum = toNum; | ||
|
||
|
||
totlePoints = [NSMutableArray array]; | ||
float dt = 1.0 / (KMaxTimes - 1); | ||
for (NSInteger i = 0; i < KMaxTimes; i ++ ) { | ||
|
||
WSPoint point = [bezier pointWithdt:dt * i]; | ||
|
||
|
||
float currTime = point.x * _duration; | ||
float currValue = point.y * (_toNum - _fromNum) + _fromNum; | ||
|
||
NSArray *array = [NSArray arrayWithObjects:[NSNumber numberWithFloat:currTime] , [NSNumber numberWithFloat:currValue], nil]; | ||
[totlePoints addObject:array]; | ||
|
||
} | ||
|
||
[self changeNumberBySelector]; | ||
|
||
} | ||
|
||
- (void)changeNumberBySelector { | ||
if (_index>= KMaxTimes) { | ||
self.text = [NSString stringWithFormat:@"%.0f",_toNum]; return; | ||
} else { | ||
NSArray *pointValues = [totlePoints objectAtIndex:_index]; | ||
_index++; | ||
float value = [(NSNumber *)[pointValues objectAtIndex:1] intValue]; | ||
float currentTime = [(NSNumber *)[pointValues objectAtIndex:0] floatValue]; | ||
float timeDuration = currentTime - _lastTime; | ||
_lastTime = currentTime; | ||
self.text = [NSString stringWithFormat:@"%.0f",value]; | ||
[self performSelector:@selector(changeNumberBySelector) withObject:nil afterDelay:timeDuration]; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
@end |
30 changes: 30 additions & 0 deletions
30
BigShow1949/Classes/Animations/04 - 渐变色和贝塞尔曲线/仿支付宝余额跳动/WSBezier.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// WSBezier.h | ||
// Test | ||
// | ||
// Created by senro wang on 15/8/11. | ||
// Copyright (c) 2015年 王燊. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
typedef struct | ||
{ | ||
float x; | ||
float y; | ||
} WSPoint; | ||
|
||
|
||
@interface WSBezier : NSObject | ||
|
||
@property (nonatomic,assign) WSPoint wsStart; | ||
@property (nonatomic,assign) WSPoint wsFirst; | ||
@property (nonatomic,assign) WSPoint wsSecond; | ||
@property (nonatomic,assign) WSPoint wsEnd; | ||
|
||
|
||
- (WSPoint )pointWithdt:(float )dt; | ||
|
||
|
||
@end |
78 changes: 78 additions & 0 deletions
78
BigShow1949/Classes/Animations/04 - 渐变色和贝塞尔曲线/仿支付宝余额跳动/WSBezier.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// WSBezier.m | ||
// Test | ||
// | ||
// Created by senro wang on 15/8/11. | ||
// Copyright (c) 2015年 王燊. All rights reserved. | ||
// | ||
|
||
#import "WSBezier.h" | ||
|
||
@implementation WSBezier | ||
|
||
|
||
- (instancetype)init{ | ||
|
||
if (self = [super init]) { | ||
|
||
|
||
[self _initPoints]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)_initPoints{ | ||
|
||
WSPoint start; | ||
WSPoint first; | ||
WSPoint second; | ||
WSPoint end; | ||
start.x = 0; | ||
start.y = 0; | ||
first.x = 0; | ||
first.y = 0.57; | ||
second.x = 0.44; | ||
second.y = 1; | ||
end.x = 1; | ||
end.y = 1; | ||
|
||
self.wsStart = start; | ||
self.wsFirst = first; | ||
self.wsSecond = second; | ||
self.wsEnd = end; | ||
|
||
} | ||
|
||
|
||
//贝塞尔 - | ||
//y=y0·(1-t)³+3·y1·t·(1-t)²+3·y2·t²·(1-t)+y3·t³ | ||
//x=x0·(1-t)³+3·x1·t·(1-t)²+3·x2·t²·(1-t)+x3·t³ | ||
|
||
|
||
//贝塞尔的 四个 控制点 | ||
//(0 , 0 ) (0 , 0.57) (0.44 , 1 ) (1 ,1); // | ||
// 还可以 设置 ease in , ease out ,ease inout ,以及spring动画 。 有需要 联系[email protected] | ||
|
||
|
||
//推荐大家一个网站 - 在这里你可以随意diy 你的 动画曲线 - | ||
//http://labs.pufen.net/cubic-bezier/#0,.57,.44,1 | ||
|
||
|
||
- (WSPoint)pointWithdt:(float )dt{ | ||
|
||
WSPoint result; | ||
|
||
float t = 1 - dt; | ||
float tSqure = t * t; | ||
float tCube = t * tSqure; | ||
float dtSqure = dt * dt; | ||
float dtCube = dtSqure * dt; | ||
|
||
result.x = self.wsStart.x * tCube + 3 * self.wsFirst.x * dt * tSqure + 3 * self.wsSecond.x * dtSqure * t + self.wsEnd.x * dtCube; | ||
result.y = self.wsStart.y * tCube + 3 * self.wsFirst.y * dt * tSqure + 3 * self.wsSecond.y * dtSqure * t + self.wsEnd.y * dtCube; | ||
return result; | ||
|
||
|
||
} | ||
|
||
@end |
13 changes: 13 additions & 0 deletions
13
BigShow1949/Classes/Animations/04 - 渐变色和贝塞尔曲线/仿支付宝余额跳动/YFAliNumberViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// YFAliNumberViewController.h | ||
// BigShow1949 | ||
// | ||
// Created by apple on 16/8/19. | ||
// Copyright © 2016年 BigShowCompany. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface YFAliNumberViewController : UIViewController | ||
|
||
@end |
Oops, something went wrong.