Skip to content

Loading…

Fix re-positioning when frame origin not (0,0). #10

Merged
merged 1 commit into from

2 participants

@nschum

Changing the radius moves the pie chart off-center, if the _pieChart frame has been set to a non-zero origin before.

@xyfeng xyfeng merged commit efbd1d1 into xyfeng:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 18, 2012
  1. @nschum
Showing with 2 additions and 1 deletion.
  1. +2 −1 XYPieChart/XYPieChart.m
View
3 XYPieChart/XYPieChart.m
@@ -211,7 +211,8 @@ - (void)setPieCenter:(CGPoint)pieCenter
- (void)setPieRadius:(CGFloat)pieRadius
{
_pieRadius = pieRadius;
- CGRect frame = CGRectMake(_pieCenter.x-pieRadius, _pieCenter.y-pieRadius, pieRadius*2, pieRadius*2);
+ CGPoint origin = _pieView.frame.origin;
+ CGRect frame = CGRectMake(origin.x+_pieCenter.x-pieRadius, origin.y+_pieCenter.y-pieRadius, pieRadius*2, pieRadius*2);
_pieCenter = CGPointMake(frame.size.width/2, frame.size.height/2);
[_pieView setFrame:frame];
[_pieView.layer setCornerRadius:_pieRadius];
Something went wrong with that request. Please try again.