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
mobileflowllc
2014-08-02 21:35:26 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
72839ea5fb2cc0d7a170ab9b552677409d806c48
72839ea5
1 parent
f78fb5cf
Add gradient color fill to circle chart
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
4 deletions
PNChart/PNBarChart/PNBar.m
PNChart/PNCircleChart/PNCircleChart.h
PNChart/PNCircleChart/PNCircleChart.m
PNChartDemo/PCChartsTableViewController.m
PNChart/PNBarChart/PNBar.m
View file @
72839ea
...
...
@@ -75,10 +75,6 @@
//gradientMask.lineWidth = 4;
gradientMask
.
lineWidth
=
self
.
frame
.
size
.
width
;
gradientMask
.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
width
,
self
.
bounds
.
size
.
height
);
CGMutablePathRef
t
=
CGPathCreateMutable
();
CGPathMoveToPoint
(
t
,
NULL
,
0
,
0
);
CGPathAddLineToPoint
(
t
,
NULL
,
self
.
bounds
.
size
.
width
,
self
.
bounds
.
size
.
height
);
gradientMask
.
path
=
progressline
.
CGPath
;
...
...
PNChart/PNCircleChart/PNCircleChart.h
View file @
72839ea
...
...
@@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, PNChartFormatType) {
@property
(
strong
,
nonatomic
)
UICountingLabel
*
countingLabel
;
@property
(
nonatomic
)
UIColor
*
strokeColor
;
@property
(
nonatomic
)
UIColor
*
strokeColorGradientStart
;
@property
(
nonatomic
)
NSNumber
*
total
;
@property
(
nonatomic
)
NSNumber
*
current
;
@property
(
nonatomic
)
NSNumber
*
lineWidth
;
...
...
PNChart/PNCircleChart/PNCircleChart.m
View file @
72839ea
...
...
@@ -101,6 +101,41 @@
_circle
.
strokeEnd
=
[
_current
floatValue
]
/
[
_total
floatValue
];
[
_countingLabel
countFrom
:
0
to
:[
_current
floatValue
]
withDuration
:
1
.
0
];
// Check if user wants to add a gradient from the start color to the bar color
if
(
_strokeColorGradientStart
)
{
// Add gradient
CAShapeLayer
*
gradientMask
=
[
CAShapeLayer
layer
];
gradientMask
.
fillColor
=
[[
UIColor
clearColor
]
CGColor
];
gradientMask
.
strokeColor
=
[[
UIColor
blackColor
]
CGColor
];
gradientMask
.
lineWidth
=
_circle
.
lineWidth
;
gradientMask
.
lineCap
=
kCALineCapRound
;
CGRect
gradientFrame
=
CGRectMake
(
0
,
0
,
2
*
self
.
bounds
.
size
.
width
,
2
*
self
.
bounds
.
size
.
height
);
gradientMask
.
frame
=
gradientFrame
;
gradientMask
.
path
=
_circle
.
path
;
CAGradientLayer
*
gradientLayer
=
[
CAGradientLayer
layer
];
gradientLayer
.
startPoint
=
CGPointMake
(
0
.
5
,
1
.
0
);
gradientLayer
.
endPoint
=
CGPointMake
(
0
.
5
,
0
.
0
);
gradientLayer
.
frame
=
gradientFrame
;
UIColor
*
endColor
=
(
_strokeColor
?
_strokeColor
:
[
UIColor
greenColor
]);
NSArray
*
colors
=
@[
(
id
)
endColor
.
CGColor
,
(
id
)
_strokeColorGradientStart
.
CGColor
];
gradientLayer
.
colors
=
colors
;
[
gradientLayer
setMask
:
gradientMask
];
[
_circle
addSublayer
:
gradientLayer
];
gradientMask
.
strokeEnd
=
[
_current
floatValue
]
/
[
_total
floatValue
];
[
gradientMask
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
}
}
...
...
PNChartDemo/PCChartsTableViewController.m
View file @
72839ea
...
...
@@ -147,6 +147,7 @@
PNCircleChart
*
circleChart
=
[[
PNCircleChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
80
.
0
,
SCREEN_WIDTH
,
100
.
0
)
andTotal
:
@100
andCurrent
:
@60
andClockwise
:
YES
andShadow
:
YES
];
circleChart
.
backgroundColor
=
[
UIColor
clearColor
];
[
circleChart
setStrokeColor
:
PNGreen
];
[
circleChart
setStrokeColorGradientStart
:[
UIColor
blueColor
]];
[
circleChart
strokeChart
];
[
viewController
.
view
addSubview
:
circleChartLabel
];
...
...
Please
register
or
login
to post a comment