Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
PNChart
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
kevinzhow
2014-02-17 04:19:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bade603f24c244de47503e5675b3396471d33ea3
bade603f
1 parent
d3467d68
Add podfile
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
218 deletions
PNChartDemo.xcodeproj/project.pbxproj
PNChartDemo/PNChart/ThirdPart/UICountingLabel.h
PNChartDemo/PNChart/ThirdPart/UICountingLabel.m
Podfile
PNChartDemo.xcodeproj/project.pbxproj
View file @
bade603
...
...
@@ -28,7 +28,6 @@
0AF7A8BE182AEB99003645C4 /* PNChartLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8BB182AEB99003645C4 /* PNChartLabel.m */; };
0AF7A8BF182AEB99003645C4 /* PNColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8BD182AEB99003645C4 /* PNColor.m */; };
9F55483E18498E0E004073B5 /* PNCircleChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F55483D18498E0E004073B5 /* PNCircleChart.m */; };
9F656B51184A4E34002E5675 /* UICountingLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F656B50184A4E34002E5675 /* UICountingLabel.m */; };
9F9AFF24185FF24000D6673D /* PNLineChartData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F9AFF21185FF24000D6673D /* PNLineChartData.m */; };
9F9AFF25185FF24000D6673D /* PNLineChartDataItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F9AFF23185FF24000D6673D /* PNLineChartDataItem.m */; };
9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FA23B0F184A5944002DBBA4 /* PCChartsTableViewController.m */; };
...
...
@@ -78,8 +77,6 @@
0AF7A8BD182AEB99003645C4 /* PNColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PNColor.m; path = PNChart/PNColor.m; sourceTree = "<group>"; };
9F55483C18498E0E004073B5 /* PNCircleChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNCircleChart.h; path = PNChart/PNCircleChart.h; sourceTree = "<group>"; };
9F55483D18498E0E004073B5 /* PNCircleChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PNCircleChart.m; path = PNChart/PNCircleChart.m; sourceTree = "<group>"; };
9F656B4F184A4E34002E5675 /* UICountingLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UICountingLabel.h; path = PNChart/ThirdPart/UICountingLabel.h; sourceTree = "<group>"; };
9F656B50184A4E34002E5675 /* UICountingLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UICountingLabel.m; path = PNChart/ThirdPart/UICountingLabel.m; sourceTree = "<group>"; };
9F9AFF20185FF24000D6673D /* PNLineChartData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNLineChartData.h; path = PNChart/PNLineChartData.h; sourceTree = "<group>"; };
9F9AFF21185FF24000D6673D /* PNLineChartData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PNLineChartData.m; path = PNChart/PNLineChartData.m; sourceTree = "<group>"; };
9F9AFF22185FF24000D6673D /* PNLineChartDataItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNLineChartDataItem.h; path = PNChart/PNLineChartDataItem.h; sourceTree = "<group>"; };
...
...
@@ -250,8 +247,6 @@
9F656B4B184A4BC9002E5675 /* PNCircleChart */ = {
isa = PBXGroup;
children = (
9F656B4F184A4E34002E5675 /* UICountingLabel.h */,
9F656B50184A4E34002E5675 /* UICountingLabel.m */,
9F55483C18498E0E004073B5 /* PNCircleChart.h */,
9F55483D18498E0E004073B5 /* PNCircleChart.m */,
);
...
...
@@ -358,7 +353,6 @@
files = (
0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */,
9F9AFF25185FF24000D6673D /* PNLineChartDataItem.m in Sources */,
9F656B51184A4E34002E5675 /* UICountingLabel.m in Sources */,
0AF7A8BF182AEB99003645C4 /* PNColor.m in Sources */,
9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */,
0AF7A8BE182AEB99003645C4 /* PNChartLabel.m in Sources */,
...
...
PNChartDemo/PNChart/ThirdPart/UICountingLabel.h
deleted
100644 → 0
View file @
d3467d6
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef
enum
{
UILabelCountingMethodEaseInOut
,
UILabelCountingMethodEaseIn
,
UILabelCountingMethodEaseOut
,
UILabelCountingMethodLinear
}
UILabelCountingMethod
;
typedef
NSString
*
(
^
UICountingLabelFormatBlock
)(
float
value
);
@interface
UICountingLabel
:
UILabel
@property
(
nonatomic
,
strong
)
NSString
*
format
;
@property
(
nonatomic
,
assign
)
UILabelCountingMethod
method
;
@property
(
nonatomic
,
copy
)
UICountingLabelFormatBlock
formatBlock
;
@property
(
nonatomic
,
copy
)
void
(
^
completionBlock
)();
-
(
void
)
countFrom
:(
float
)
startValue
to
:(
float
)
endValue
;
-
(
void
)
countFrom
:(
float
)
startValue
to
:(
float
)
endValue
withDuration
:(
NSTimeInterval
)
duration
;
@end
PNChartDemo/PNChart/ThirdPart/UICountingLabel.m
deleted
100644 → 0
View file @
d3467d6
#import "UICountingLabel.h"
#if !__has_feature(objc_arc)
#error UICountingLabel is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
#pragma mark - UILabelCounter
// This whole class & subclasses are private to UICountingLabel, which is why they are declared here in the .m file
@interface
UILabelCounter
:
NSObject
-
(
float
)
update
:(
float
)
t
;
@property
float
rate
;
@end
@interface
UILabelCounterLinear
:
UILabelCounter
@end
@interface
UILabelCounterEaseIn
:
UILabelCounter
@end
@interface
UILabelCounterEaseOut
:
UILabelCounter
@end
@interface
UILabelCounterEaseInOut
:
UILabelCounter
@end
@implementation
UILabelCounter
-
(
float
)
update
:(
float
)
t
{
return
0
;
}
@end
@implementation
UILabelCounterLinear
-
(
float
)
update
:(
float
)
t
{
return
t
;
}
@end
@implementation
UILabelCounterEaseIn
-
(
float
)
update
:(
float
)
t
{
return
powf
(
t
,
self
.
rate
);
}
@end
@implementation
UILabelCounterEaseOut
-
(
float
)
update
:(
float
)
t
{
return
1
.
0
-
powf
((
1
.
0
-
t
),
self
.
rate
);
}
@end
@implementation
UILabelCounterEaseInOut
-
(
float
)
update
:
(
float
)
t
{
int
sign
=
1
;
int
r
=
(
int
)
self
.
rate
;
if
(
r
%
2
==
0
)
sign
=
-
1
;
t
*=
2
;
if
(
t
<
1
)
return
0
.
5
f
*
powf
(
t
,
self
.
rate
);
else
return
sign
*
0
.
5
f
*
(
powf
(
t
-
2
,
self
.
rate
)
+
sign
*
2
);
}
@end
#pragma mark - UICountingLabel
@interface
UICountingLabel
()
@property
float
startingValue
;
@property
float
destinationValue
;
@property
NSTimeInterval
progress
;
@property
NSTimeInterval
lastUpdate
;
@property
NSTimeInterval
totalTime
;
@property
float
easingRate
;
@property
(
nonatomic
,
strong
)
UILabelCounter
*
counter
;
@end
@implementation
UICountingLabel
-
(
void
)
countFrom
:(
float
)
value
to
:(
float
)
endValue
{
[
self
countFrom
:
value
to
:
endValue
withDuration
:
2
.
0
f
];
}
-
(
void
)
countFrom
:(
float
)
startValue
to
:(
float
)
endValue
withDuration
:(
NSTimeInterval
)
duration
{
self
.
easingRate
=
3
.
0
f
;
self
.
startingValue
=
startValue
;
self
.
destinationValue
=
endValue
;
self
.
progress
=
0
;
self
.
totalTime
=
duration
;
self
.
lastUpdate
=
[
NSDate
timeIntervalSinceReferenceDate
];
if
(
self
.
format
==
nil
)
self
.
format
=
@"%f"
;
switch
(
self
.
method
)
{
case
UILabelCountingMethodLinear
:
self
.
counter
=
[[
UILabelCounterLinear
alloc
]
init
];
break
;
case
UILabelCountingMethodEaseIn
:
self
.
counter
=
[[
UILabelCounterEaseIn
alloc
]
init
];
break
;
case
UILabelCountingMethodEaseOut
:
self
.
counter
=
[[
UILabelCounterEaseOut
alloc
]
init
];
break
;
case
UILabelCountingMethodEaseInOut
:
self
.
counter
=
[[
UILabelCounterEaseInOut
alloc
]
init
];
break
;
}
self
.
counter
.
rate
=
3
.
0
f
;
NSTimer
*
timer
=
[
NSTimer
timerWithTimeInterval
:(
1
.
0
f
/
30
.
0
f
)
target
:
self
selector
:
@selector
(
updateValue
:
)
userInfo
:
nil
repeats
:
YES
];
[[
NSRunLoop
mainRunLoop
]
addTimer
:
timer
forMode
:
NSRunLoopCommonModes
];
}
-
(
void
)
updateValue
:(
NSTimer
*
)
timer
{
// update progress
NSTimeInterval
now
=
[
NSDate
timeIntervalSinceReferenceDate
];
self
.
progress
+=
now
-
self
.
lastUpdate
;
self
.
lastUpdate
=
now
;
if
(
self
.
progress
>=
self
.
totalTime
)
{
[
timer
invalidate
];
self
.
progress
=
self
.
totalTime
;
}
float
percent
=
self
.
progress
/
self
.
totalTime
;
float
updateVal
=
[
self
.
counter
update
:
percent
];
float
value
=
self
.
startingValue
+
(
updateVal
*
(
self
.
destinationValue
-
self
.
startingValue
));
if
(
self
.
formatBlock
!=
nil
)
{
self
.
text
=
self
.
formatBlock
(
value
);
}
else
{
// check if counting with ints - cast to int
if
([
self
.
format
rangeOfString
:
@"%(.*)d"
options
:
NSRegularExpressionSearch
].
location
!=
NSNotFound
||
[
self
.
format
rangeOfString
:
@"%(.*)i"
].
location
!=
NSNotFound
)
{
self
.
text
=
[
NSString
stringWithFormat
:
self
.
format
,(
int
)
value
];
}
else
{
self
.
text
=
[
NSString
stringWithFormat
:
self
.
format
,
value
];
}
}
if
(
self
.
progress
==
self
.
totalTime
&&
self
.
completionBlock
!=
nil
)
{
self
.
completionBlock
();
self
.
completionBlock
=
nil
;
}
}
@end
Podfile
0 → 100644
View file @
bade603
platform
:ios
,
'6.0'
pod
"PNChart"
,
"~>0.3.2"
...
...
Please
register
or
login
to post a comment