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 7576001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:49:04+00:00 2026-05-30T16:49:04+00:00

I wanted to draw different set of lines in the same loop inside drawRect

  • 0

I wanted to draw different set of lines in the same loop inside drawRect but with different color.
say set of lines with blue and the other with red alternatively.

initially, I was using two different for loops and and stroking the context twice with different colors.

But then I came across CGMutablePathRef and decided to use two different paths and stroke them with different colors and write code in the same for loop.

Now my problem is that I couldn’t find way to set a color for a path.
It appears that we can only set color for Context and not to paths.

I am quite new to iOS and cocoa.

What should I do ? Shall I add the first path to context, set the color, stroke the path and then add the other stroke to the context and set the new color and stroke the context again.

Is there a better,neater and cleaner way for doing this ?

  • 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-05-30T16:49:05+00:00Added an answer on May 30, 2026 at 4:49 pm

    Shall I add the first path to context, set the color, stroke the path and then add the other stroke to the context and set the new color and stroke the context again.

    Yes, that’s how you do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I wanted to draw arrows instead of axis lines using one of the
I draw a triangle using mouse drag. After drawing many different triangles, I wanted
I wanted to show the users Name Address (see www.ipchicken.com ), but the only
I wanted to generate one fix view using interface builder, but the size of
just wanted to gather different ideas and perspectives as to which layer should (and
Does the same connection string used on two different physical servers hosting different web
I know there is this question that is very similar, but I wanted to
I'm developing a Facebook app which allow my users to draw their wanted path
I wanted to draw special characters like this one ( http://www.fileformat.info/info/unicode/char/2605/index.htm ) in JLabel.
I wanted to make a class Draw which will have static method ConsoleSquare() and

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.