Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func drawDisk(color: UIColor, rectForDisk: CGRect = CGRectMake(0.0, 0.0, 1.0, 1.0), withStroke: Bool) -> UIImage {
- UIGraphicsBeginImageContextWithOptions(rectForDisk.size, false, 0.0)
- let context = UIGraphicsGetCurrentContext()
- CGContextSetFillColorWithColor(context, color.CGColor)
- CGContextFillEllipseInRect(context, rectForDisk)
- let rectForCircle = CGRectMake(0.5, 0.5, rectForDisk.size.width - 1, rectForDisk.size.height - 1)
- CGContextSetLineWidth(context, withStroke ? 1.0 : 0)
- CGContextSetStrokeColorWithColor(context,
- UIColor.blackColor().CGColor)
- CGContextAddEllipseInRect(context, rectForCircle)
- CGContextStrokePath(context)
- let image = UIGraphicsGetImageFromCurrentImageContext()
- UIGraphicsEndImageContext()
- return image
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement