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

  • Home
  • SEARCH
  • 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 7495477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:09:41+00:00 2026-05-29T18:09:41+00:00

I would like to create a UIBezierPath with 10px rounded corners and with gradient

  • 0

I would like to create a UIBezierPath with 10px rounded corners and with gradient fill. How can I acheive this effect?

Here’s an image of what I want to do:

enter image description here

As you can see, this square has:

  • 2px black border
  • 10px rounded corners
  • red to green linear gradient fill

How can I do this programatically without using pattern image color?

Here’s how I create the path:

UIBezierPath *border = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:10.0f];
[border setLineWidth:2];
[[UIColor blackColor] setStroke];
[border stroke];
[[UIColor redColor] setFill]; <-- what should I put here?
[border fill];
  • 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-29T18:09:42+00:00Added an answer on May 29, 2026 at 6:09 pm

    3 ways that I can think of.

    1. Create a CAGradientLayer and insert it as a sublayer of theView.layer. You can even put a rounded corner radius on the layer. Of course you’ll have to import QuartzCore framework.

    2. Do it with CoreGraphics, like so:

      CGGradientRef gradient;
      CGColorSpaceRef colorspace;
      size_t num_locations = 2;
      CGFloat locations[2] = { 0.0, 1.0 };
      CGFloat components[8] = { 1.0, 0.0, 0.0, 1.0,  // Start color
              0.0, 1.0, 0.0, 1.0 }; // End color
      
      colorspace = CGColorSpaceCreateDeviceRGB();
      gradient = CGGradientCreateWithColorComponents (colorspace, components, locations, num_locations);
      CGContextDrawLinearGradient (ctx, gradient, gradientStartPoint, gradientEndPoint, 0);
      CGGradientRelease(gradient);
      
    3. Create an off-screen image context that’s one pixel wide and has a gradient, generate the image, then set the background color with colorWithPatternImage.

    These are in order of easiest to hardest.

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

Sidebar

Related Questions

I would like to know how can I create something that looks like what
I would like create a database using value from a variable. Here my script
In my application I would like create a settings where user can be able
I would like to create a main overview chart with asp:chart control, like this:
I would like to create an XML file like this: <?xml version=1.0 encoding=UTF-8?> <text>
I would like create alarm clock at windows phone 7 mango , for this
i would like create a menu with kdialog like this kdialog --menu choose your
Good afternoon, I would like create a application that can can create folders and
I would like to create a browser-based network game. To ensure it can be
I would like create my own collection that has all the attributes of python

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.