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
Kevin
2015-08-24 11:56:40 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8901cc38dfa106ba18c0eb045eb8e2c969fe8ebf
8901cc38
2 parents
4e4cde63
6fca83db
Merge pull request #240 from NoICE/0.8.6-autolayout
PieChart: redraw chart if layout changed
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
PNChart/PNPieChart.h
PNChart/PNPieChart.m
PNChart/PNPieChart.h
View file @
8901cc3
...
...
@@ -44,8 +44,16 @@
/** Default YES. */
@property
(
nonatomic
)
BOOL
shouldHighlightSectorOnTouch
;
/** Current outer radius. Override recompute() to change this. **/
@property
(
nonatomic
)
CGFloat
outerCircleRadius
;
/** Current inner radius. Override recompute() to change this. **/
@property
(
nonatomic
)
CGFloat
innerCircleRadius
;
@property
(
nonatomic
,
weak
)
id
<
PNChartDelegate
>
delegate
;
-
(
void
)
strokeChart
;
-
(
void
)
recompute
;
@end
...
...
PNChart/PNPieChart.m
View file @
8901cc3
...
...
@@ -15,9 +15,6 @@
@property
(
nonatomic
)
NSArray
*
items
;
@property
(
nonatomic
)
NSArray
*
endPercentages
;
@property
(
nonatomic
)
CGFloat
outerCircleRadius
;
@property
(
nonatomic
)
CGFloat
innerCircleRadius
;
@property
(
nonatomic
)
UIView
*
contentView
;
@property
(
nonatomic
)
CAShapeLayer
*
pieLayer
;
@property
(
nonatomic
)
NSMutableArray
*
descriptionLabels
;
...
...
@@ -48,9 +45,6 @@
self
=
[
self
initWithFrame
:
frame
];
if
(
self
){
_items
=
[
NSArray
arrayWithArray
:
items
];
_outerCircleRadius
=
CGRectGetWidth
(
self
.
bounds
)
/
2
;
_innerCircleRadius
=
CGRectGetWidth
(
self
.
bounds
)
/
6
;
_descriptionTextColor
=
[
UIColor
whiteColor
];
_descriptionTextFont
=
[
UIFont
fontWithName
:
@"Avenir-Medium"
size
:
18
.
0
];
_descriptionTextShadowColor
=
[[
UIColor
blackColor
]
colorWithAlphaComponent
:
0
.
4
];
...
...
@@ -86,12 +80,20 @@
_pieLayer
=
[
CAShapeLayer
layer
];
[
_contentView
.
layer
addSublayer
:
_pieLayer
];
}
/** Override this to change how inner attributes are computed. **/
-
(
void
)
recompute
{
self
.
outerCircleRadius
=
CGRectGetWidth
(
self
.
bounds
)
/
2
;
self
.
innerCircleRadius
=
CGRectGetWidth
(
self
.
bounds
)
/
6
;
}
#pragma mark -
-
(
void
)
strokeChart
{
[
self
loadDefault
];
[
self
recompute
];
PNPieChartDataItem
*
currentItem
;
for
(
int
i
=
0
;
i
<
_items
.
count
;
i
++
)
{
...
...
@@ -443,4 +445,11 @@
[
squareImageView
setFrame
:
CGRectMake
(
originX
,
originY
,
size
,
size
)];
return
squareImageView
;
}
/* Redraw the chart on autolayout */
-
(
void
)
layoutSubviews
{
[
super
layoutSubviews
];
[
self
strokeChart
];
}
@end
...
...
Please
register
or
login
to post a comment