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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:51:59+00:00 2026-05-11T14:51:59+00:00

I am attempting to implement a custom view. This view should display an image

  • 0

I am attempting to implement a custom view. This view should display an image surrounded by a gray, rounded rect border. I can get the image to display fine, as well as the border, however, since the border has rounded corners, I need a way to clear those corners such that they correctly display whatever is behind the view. How can I accomplish this?

It seems like I might be able to use CGContextClearRect, but then wouldn’t I have to call this multiple times, reconstructing the area outside of my rounded corner? That sounds overly complicated.

Is there a better way to create this view?

Here is my current code:

- (void)drawRect:(CGRect)rect {     CGContextRef context = UIGraphicsGetCurrentContext();      // Draw the image. This will completely fill the current rect.     [image drawInRect:self.bounds];      // Ensure we draw completely within our bounds instead of straddling it.     CGRect rrect = self.bounds;     rrect.size.height = rrect.size.height - 1.0;     rrect.size.width = rrect.size.width - 1.0;     rrect.origin.x = rrect.origin.x + (1.0 / 2);     rrect.origin.y = rrect.origin.y + (1.0 / 2);      CGFloat radius = 5.0;     CGFloat minx = CGRectGetMinX(rrect);     CGFloat midx = CGRectGetMidX(rrect);     CGFloat maxx = CGRectGetMaxX(rrect);     CGFloat miny = CGRectGetMinY(rrect);     CGFloat midy = CGRectGetMidY(rrect);     CGFloat maxy = CGRectGetMaxY(rrect);      // Draw the rounded rect border.     CGContextSetRGBStrokeColor(context, 0.6, 0.6, 0.6, 1.0);     CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 0.0);     CGContextSetLineWidth(context, 1.0);     CGContextMoveToPoint(context, minx, midy);     CGContextAddArcToPoint(context, minx, miny, midx, miny, radius);     CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius);     CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius);     CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius);     CGContextClosePath(context);     CGContextDrawPath(context, kCGPathFillStroke); } 
  • 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. 2026-05-11T14:51:59+00:00Added an answer on May 11, 2026 at 2:51 pm

    Add the rounded-rect path to the clipping path before drawing the image.

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

Sidebar

Related Questions

I am currently attempting to implement a custom gridview interface to display data from
I am attempting to implement the suckerfish menu found on this tutorial. I get
I am attempting to impliment a custom view engine to serve mobile views based
I'm attempting to implement custom termination behavior in a Cocoa application. Normally when my
I am attempting to implement a custom locale service in an MVC 2 webpage.
I'm attempting to implement a custom search dialog in a WPF program. The Parent
I'm trying to implement a custom SessionIDManager very similar this example . I'm putting
I am attempting to implement a quiet uninstall of my application. This works great
I am trying to work out why I can't get JQuery Rounded Corners working
I have a web form that I am attempting to implement dynamic drop down

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.