Tuesday, August 2, 2011

How to create fragmented disk with QuartzCore ?

You want to create a fragmented disk which looks like following:



































You can simply use the code of piechart provided on this blog(HERE) and clear smaller circle in the center with kCGBlendModeClear on as shown in code of lines below.



    
    CGContextSetFillColorWithColor( context, [UIColor whiteColor].CGColor );
    CGContextSetBlendMode(context, kCGBlendModeClear);
    CGRect holeRect= CGRectMake((_outerRadius-_innerRadius)/2, (_outerRadius-_innerRadius)/2, _innerRadius, _innerRadius);
    CGContextFillEllipseInRect( context, holeRect );





1 comment: