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
Matthew Strickland
2014-03-13 11:17:13 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f2543ac18e3ff003c7bf35b209a694b6c20506d5
f2543ac1
1 parent
c00c6ada
Add ability for PNCircleChart to go clockwise (current behavior is counter clockwise).
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
PNChart/PNCircleChart.h
PNChart/PNCircleChart.m
PNChartDemo/PCChartsTableViewController.m
PNChart/PNCircleChart.h
View file @
f2543ac
...
...
@@ -15,13 +15,14 @@
@interface
PNCircleChart
:
UIView
-
(
void
)
strokeChart
;
-
(
id
)
initWithFrame
:(
CGRect
)
frame
andTotal
:(
NSNumber
*
)
total
andCurrent
:(
NSNumber
*
)
current
;
-
(
id
)
initWithFrame
:(
CGRect
)
frame
andTotal
:(
NSNumber
*
)
total
andCurrent
:(
NSNumber
*
)
current
andClockwise
:(
BOOL
)
clockwise
;
@property
(
nonatomic
,
strong
)
UIColor
*
strokeColor
;
@property
(
nonatomic
,
strong
)
UIColor
*
labelColor
;
@property
(
nonatomic
,
strong
)
NSNumber
*
total
;
@property
(
nonatomic
,
strong
)
NSNumber
*
current
;
@property
(
nonatomic
,
strong
)
NSNumber
*
lineWidth
;
@property
(
nonatomic
)
BOOL
clockwise
;
@property
(
nonatomic
,
strong
)
CAShapeLayer
*
circle
;
@property
(
nonatomic
,
strong
)
CAShapeLayer
*
circleBG
;
...
...
PNChart/PNCircleChart.m
View file @
f2543ac
...
...
@@ -26,17 +26,20 @@
}
-
(
id
)
initWithFrame
:
(
CGRect
)
frame
andTotal
:
(
NSNumber
*
)
total
andCurrent
:
(
NSNumber
*
)
current
{
-
(
id
)
initWithFrame
:
(
CGRect
)
frame
andTotal
:
(
NSNumber
*
)
total
andCurrent
:
(
NSNumber
*
)
current
andClockwise
:
(
BOOL
)
clockwise
{
self
=
[
super
initWithFrame
:
frame
];
if
(
self
)
{
_total
=
total
;
_current
=
current
;
_strokeColor
=
PNFreshGreen
;
_clockwise
=
clockwise
;
CGFloat
startAngle
=
clockwise
?
-
90
.
0
f
:
270
.
0
f
;
CGFloat
endAngle
=
clockwise
?
-
90
.
01
f
:
270
.
01
f
;
_lineWidth
=
[
NSNumber
numberWithFloat
:
8
.
0
];
UIBezierPath
*
circlePath
=
[
UIBezierPath
bezierPathWithArcCenter
:
CGPointMake
(
self
.
center
.
x
,
self
.
center
.
y
)
radius
:
self
.
frame
.
size
.
height
*
0
.
5
startAngle
:
DEGREES_TO_RADIANS
(
270
)
endAngle
:
DEGREES_TO_RADIANS
(
270
.
01
)
clockwise
:
NO
];
UIBezierPath
*
circlePath
=
[
UIBezierPath
bezierPathWithArcCenter
:
CGPointMake
(
self
.
center
.
x
,
self
.
center
.
y
)
radius
:
self
.
frame
.
size
.
height
*
0
.
5
startAngle
:
DEGREES_TO_RADIANS
(
startAngle
)
endAngle
:
DEGREES_TO_RADIANS
(
endAngle
)
clockwise
:
clockwise
];
_circle
=
[
CAShapeLayer
layer
];
_circle
.
path
=
circlePath
.
CGPath
;
...
...
PNChartDemo/PCChartsTableViewController.m
View file @
f2543ac
...
...
@@ -127,7 +127,7 @@
circleChartLabel
.
font
=
[
UIFont
fontWithName
:
@"Avenir-Medium"
size
:
23
.
0
];
circleChartLabel
.
textAlignment
=
NSTextAlignmentCenter
;
PNCircleChart
*
circleChart
=
[[
PNCircleChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
80
.
0
,
SCREEN_WIDTH
,
100
.
0
)
andTotal
:[
NSNumber
numberWithInt
:
100
]
andCurrent
:
[
NSNumber
numberWithInt
:
60
]];
PNCircleChart
*
circleChart
=
[[
PNCircleChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
80
.
0
,
SCREEN_WIDTH
,
100
.
0
)
andTotal
:[
NSNumber
numberWithInt
:
100
]
andCurrent
:
[
NSNumber
numberWithInt
:
60
]
andClockwise
:
NO
];
circleChart
.
backgroundColor
=
[
UIColor
clearColor
];
[
circleChart
setStrokeColor
:
PNGreen
];
[
circleChart
strokeChart
];
...
...
Please
register
or
login
to post a comment