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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:06:22+00:00 2026-05-25T02:06:22+00:00

I have a custom shape of an arrow set up in code. What I’m

  • 0

I have a custom shape of an arrow set up in code. What I’m trying to do is fill it with gradient. Problem is, I have no idea how to fill a non rectangular shape (space inside dark frame) with gradient. Any ideas?

 //Define colours used in drawing
CGContextRef context = UIGraphicsGetCurrentContext();

CGColorRef lightColor = _lightColor.CGColor;
CGColorRef darkColor = _darkColor.CGColor;
CGColorRef shadowColor = [UIColor colorWithRed:0.2 green:0.2 
                                          blue:0.2 alpha:0.5].CGColor;   

//Get label text size to help determine sizes for drawing
CGSize textSize = [[_titleLabel text] sizeWithFont:[_titleLabel font]];

//Set shadow
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, CGSizeMake(0, 2), 3.0, shadowColor);

//Set arrow shape
CGPoint rectangle_points[] =
{
    CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y),
    CGPointMake(textSize.width+10, _coloredBoxRect.origin.y),
    CGPointMake(textSize.width+40, _coloredBoxRect.origin.y+20),
    CGPointMake(textSize.width+10, _coloredBoxRect.origin.y+40),
    CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y+40),
    CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y),
};
CGContextAddLines(context, rectangle_points, 6);    
CGContextSetFillColorWithColor(context, lightColor);
CGContextFillPath(context);

CGContextRestoreGState(context);

//Draw dark frame for the arrow
CGContextSetStrokeColorWithColor(context, darkColor);
CGContextSetLineWidth(context, 1.0);  
CGContextSaveGState(context);
draw1PxStroke(context, CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y), CGPointMake(textSize.width+10, _coloredBoxRect.origin.y), darkColor);
draw1PxStroke(context, CGPointMake(textSize.width+10, _coloredBoxRect.origin.y+40), CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y+40), darkColor);
draw1PxStroke(context, CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y), CGPointMake(_coloredBoxRect.origin.x, _coloredBoxRect.origin.y+40), darkColor);
draw1PxStroke(context, CGPointMake(textSize.width+10, _coloredBoxRect.origin.y), CGPointMake(textSize.width+40, _coloredBoxRect.origin.y+20), darkColor);
draw1PxStroke(context, CGPointMake(textSize.width+10, _coloredBoxRect.origin.y+40), CGPointMake(textSize.width+40, _coloredBoxRect.origin.y+20), darkColor);    
CGContextRestoreGState(context);
  • 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-25T02:06:22+00:00Added an answer on May 25, 2026 at 2:06 am

    Check out this apple sample application.
    It has exactly what u need in the “Polygons” section (for filling a polygon).
    What you need to change is drawing the gradient instead of drawing as in the example.
    Drawing gradients is also exemplified in the sample, under the “Gradients” section.

    http://developer.apple.com/library/ios/#samplecode/QuartzDemo/Introduction/Intro.html

    Hope this helps,
    Vlad

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

Sidebar

Related Questions

Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I have created a custom shape, essentially it is a collection of four Arc2D
Is there any way to have a custom-shape image container? To use something instead
Can I make a div with a custom shape? I mean, I have a
I have a custom Shape - MyShape - (may be control, does not matter).
WPF, Shapes I have a custom Shape , and try to implement MouseClick and
I am trying to create a button that has a custom shape (hexagon), but
I have a custom drawable rounded_corner.xml: <?xml version=1.0 encoding=UTF-8?> <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <gradient android:startColor=#FFFFFF
I have a custom line shape with start and end point. The ActualWidth and
I'm using a custom JLayeredPane. I have several Shapes which needed to be drawn

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.