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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:51:51+00:00 2026-05-21T07:51:51+00:00

I am trying to apply the same gradient as per the screen shot below

  • 0

I am trying to apply the same gradient as per the screen shot below using CGGradientCreateWithColorComponents.

This is what I’m using at the moment, however it’s not quite right and I’m after a better way of trying to guess these values. I’d also like to know how to actually determine what these values are as this code was grabbed from a tutorial, which didn’t explain much at all in terms of what the components are.

CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[8] = { 1, 1, 1, 1, 0.866, 0.866, 0.866, 1 };
CGFloat locations[2] = { 0.0, 1.0 };

CGGradientRef myGradient = CGGradientCreateWithColorComponents(myColorspace, components, locations, 2);

enter image description here

  • 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-21T07:51:51+00:00Added an answer on May 21, 2026 at 7:51 am

    I’ve played around with it and got this picture:

    enter image description here

    with colors:

    static const CGFloat colors [] = { 
    0.894, 0.894, 0.894, 1.0, 
    0.694, 0.694, 0.694, 1.0
    };
    

    using this piece of code:

    - (void) drawRect:(CGRect)rect {
       CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB();
       CGGradientRef gradient = CGGradientCreateWithColorComponents(baseSpace, colors, NULL, 2);
       CGColorSpaceRelease(baseSpace), baseSpace = NULL;
    
       CGContextRef context = UIGraphicsGetCurrentContext();
       CGContextClearRect(context, rect);
       CGContextSaveGState(context);
    
       CGPoint startPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect));
       CGPoint endPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect));
    
       CGContextClip(context);
       CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
    
       CGGradientRelease(gradient), gradient = NULL;
    
       CGContextRestoreGState(context);
       [super drawRect:rect];
     }
    

    I dont know if it’s close enough.

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

Sidebar

Related Questions

I have prepared a r script and trying to apply the same codes in
im trying to apply this JSON code to my Google Map: [ { stylers:
I am trying to apply some transformations on images using a CGContextRef. I am
I am trying to apply a method to an existing object which involves using
I'm really lost on this case. I am trying to apply a custom MVC
I am trying to apply a thirdparty LAF to a NetBeans RCP application (not
Basically I'm trying to do the same thing as this question but with Fluent
I'm trying to figure out how to apply a for-loop to this script and
I'm trying to apply a .patch file to a single .cpp file using git
I'm trying to apply jQuery UI autocomplete to three input boxes at the same

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.