I'm trying to input the arguments for CGContextSetRGBFillColor
using a data type. For example:
NSString *colorcode = ctx, 0, 1, 0, 0;
CGContextSetRGBFillColor(colorcode);
But I get an error saying that I have too few arguments.
I want to change the arguments (ctx, 0, 1, 0, 1 )
sent to CGContextSetRGBFillColor
depending on the users actions.
I want to input the argument for CGContextSetRGBFillColor
using a data type because the values of it is set in a separate view controller. Or can I directly input the arguments to CGContextSetRGBFillColor
and then bring it over to the other view controller to use it?
Try using a UIColor
object to store the user's selected color. You can create one like this:
UIColor *color = [UIColor colorWithRed:0 green:1 blue:0 alpha:0];
Then when it's time to use it as the fill color, you can do this:
CGContextSetFillColorWithColor(ctx, color.CGColor);
I should mention that if you are not using ARC, you need to retain and release color appropriately.
Sounds like what you really need to be doing is:
CGContextSetRGBFillColor (ctx, 0.0f, 1.0f, 0.0f, 1.0f);
Where each color component is some fraction between 0.0 and 1.0.
Why are you using a NSString?
Here is the documentation on Apple's website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With