Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting colors for CGContextRef

I was just wondering how does setStroke know to set the stroke for context when context isn't mentioned at all in the setStroke method?

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 10);
[[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0] setStroke];

Btw how often do you programmatically draw your own objects?

like image 668
stumped Avatar asked Dec 06 '25 10:12

stumped


1 Answers

This is the implementation of setStroke for your color:

- (void)setStroke {
    CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), self.CGColor);
}

It uses the same function to get the context that you're using.

like image 111
rob mayoff Avatar answered Dec 08 '25 03:12

rob mayoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!