Powerful pie layer for creating your own pie view. PieLayer provide great animation with simple usage.
The main advantage of that control that there is no worry about displaying of animation. Animation will display correctly even if you will add new elements during execution of another slice deleting animation. That's amazing! And here is no delegates. I like delegates, but in this case I think they are excess.
Be creative =)
Edit your PodFile
to include the following line:
pod 'MagicPie'
Then import the main header.
#import <MagicPie.h>
Have a fun!
Okay, now when you are reading this, I recommend to you look the example #2 in Swift.
Create pie:
PieLayer* pieLayer = [[PieLayer alloc] init];
pieLayer.frame = CGRectMake(0, 0, 200, 200);
[self.view.layer addSublayer:pieLayer];
let pieLayer = PieLayer()
pieLayer.frame = CGRectMake(0, 0, 200, 200)
view.layer.addSublayer(pieLayer)
Add slices:
[pieLayer addValues:@[[PieElement pieElementWithValue:5.0 color:[UIColor redColor]],
[PieElement pieElementWithValue:4.0 color:[UIColor blueColor]],
[PieElement pieElementWithValue:7.0 color:[UIColor greenColor]]] animated:YES];
pieLayer.addValues([PieElement(value: 5.0, color: UIColor.redColor()),
PieElement(value: 4.0, color: UIColor.blueColor()),
PieElement(value: 7.0, color: UIColor.greenColor())], animated: true)
Change value with animation:
PieElement* pieElem = pieLayer.values[0];
[PieElement animateChanges:^{
pieElem.val = 13.0;
pieElem.color = [UIColor yellowColor];
}];
let pieElem = pieLayer.values[0]
PieElement.animateChanges {
pieElem.val = 13.0
pieElem.color = UIColor.yellowColor()
}
Delete slices:
[pieLayer deleteValues:@[pieLayer.values[0], pieLayer.values[1]] animated:YES];
pieLayer.deleteValues([pieLayer.values[0], pieLayer.values[1]], animated: true)
Alexandr Graschenkov: [email protected]
MagicPie is available under the MIT license.
Copyright © 2013 Alexandr Graschenkov.