Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8116291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:46:46+00:00 2026-06-06T03:46:46+00:00

I was wondering if anyone could help me implement color selection in my iOS

  • 0

I was wondering if anyone could help me implement color selection in my iOS app. Right now, the painting line is only black, but I’d like the user to be able to change the color. Right now I have 5 buttons for 5 different color options. I then tagged each button 1-5, and connected them all to a single IBAction. I was thinking I could have an if statement to say if the button is tagged 1, then set color to 1.0, 0.0, 0.0, 1.0 (red) and so on for each color.
So, here are the if statements I have:

NSString *color = @"0.15, 1.15, 0.15, .8";

-(IBAction)color:(id)sender{

    if ([sender tag] ==1) {
        color = @"0.15, 1.15, 0.15, .8";
    }
    if ([sender tag] ==2) {
        color = @"0.15, 1.15, 0.15, .8";
    }
    if ([sender tag] ==3) {
        color = @"0.15, 1.15, 0.15, .8);";
    }
    if ([sender tag] ==4) {
        color = @"(0.15, 1.15, 0.15, .8";
    }
    if ([sender tag] ==5) {
        color = @"0.15, 1.15, 0.15, .8";
    }
}

So, now that I put the variable color in

CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), color );

But, I’m getting the error “Too few arguments to function call, expected 5, have 2”

Thanks for your help!

-Karl

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:46:55+00:00Added an answer on June 6, 2026 at 3:46 am

    Thanks for all your help, but I figured out the last part on my own.
    If anyone’s interested, this is the code I came up with:

    double C1 = 1.15;
    double C2 = 0.15;
    double C3 = 0.15;
    double C4 = .8;
    
    'NSString *color = @"0.15, 1.15, 0.15, .8";
    
    -(IBAction)colors:(id)sender{
    
    if (([sender tag] ==1)) {
        C1=  0.15;
        C2 = 0.15;
        C3 = 0.15;
        C4 = .8;
    }
    
    else if (([sender tag] ==2)) {
    
        C1 = 0.15;
        C2 = 1.15;
        C3 = 0.15;
        C4 = .8;
    }
    
    else if (([sender tag] ==3)) {
        color = @"1.15, 0.15, 0.15, .8";
        C1 = 1.15;
        C2 = 0.15;
        C3 = 0.15;
        C4 = .8;
    }
    
    else if (([sender tag] ==4)) {
        C1 = 0.15;
        C2 = 0.15;
        C3 = 1.15;
        C4 = .8;
    }
    else if (([sender tag] ==5)) {
        C1 = 1.15;
        C2 = 1.15;
        C3 = 0.15;
        C4 = .8;
    }
    
    }
    
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), C1, C2, C3, C4 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if anyone could tell me how to implement line 45 of
Hey there, was wondering if anyone could help a newbie on SQL and Python.
I was just wondering if anyone could help me create a mysql function UUID_SHORT()
I was wondering if anyone could help me animate an image on hover that
I was wondering if anyone could help me out (not with code, although that
I was wondering if anyone could help me out, I'm trying to find a
I was wondering if anyone could help me out with jQuery file tree (
I was wondering if anyone could help me get the leading zero to show
Hey everyone - I am wondering if anyone could help me out - I
Hi guys I was wondering if anyone could help me out, I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.