Created
December 17, 2013 11:00
-
-
Save cyndibaby905/8003205 to your computer and use it in GitHub Desktop.
Draw circle with two colors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat borderWidth = 3.f; | |
CGFloat circleRadius = self.bounds.size.width / 2 - borderWidth; | |
CGPoint circleCenter = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetStrokeColorWithColor(context, [[UIColor colorWithRed:255.0/255.0 green:210.0/255.0 blue:60.0/255.0 alpha:1] CGColor]); | |
UIBezierPath *firstHalf = [UIBezierPath bezierPath]; | |
[firstHalf addArcWithCenter:circleCenter radius:circleRadius startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES]; | |
[firstHalf setLineWidth:borderWidth]; | |
[firstHalf stroke]; | |
CGContextSetStrokeColorWithColor(context, [[UIColor colorWithRed:255.0/255.0 green:109.0/255.0 blue:38.0/255.0 alpha:1] CGColor]); | |
UIBezierPath *secondHalf = [UIBezierPath bezierPath]; | |
[secondHalf addArcWithCenter:circleCenter radius:circleRadius startAngle:M_PI_2 endAngle:3.0 * M_PI_2 clockwise:YES]; | |
[secondHalf setLineWidth:borderWidth]; | |
[secondHalf stroke]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment