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 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

Ask A Question

Stats

  • Questions 102k
  • Answers 102k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Instead of plain text have you tried using HTML and… May 11, 2026 at 8:12 pm
  • Editorial Team
    Editorial Team added an answer Databindings "bind" to a provided "View", currently you are binding… May 11, 2026 at 8:12 pm
  • Editorial Team
    Editorial Team added an answer In pure javascript, this would not be an easy task,… May 11, 2026 at 8:12 pm

Related Questions

I am attempting to return a collection of departments from a .NET assembly to
I'm using a remote 3rd party storage solution that does not have support for
I have a web form that I am attempting to implement dynamic drop down
I am attempting to implement global error handling in my MVC application. I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.