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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:47:43+00:00 2026-06-17T08:47:43+00:00

I’m trying to add a shadow behind a circular view, but my attempts have

  • 0

I’m trying to add a shadow behind a circular view, but my attempts have led me to only a shadow on my view’s border—and this shadow doesn’t appear all the way around the view either (just the top). Here’s my code:

-(void)drawRect:(CGRect)dirtyRect{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGRect bounds=[self bounds];

    // Figure out the centre of the bounds rectangle
    CGPoint centre;
    centre.x=bounds.origin.x+0.5*bounds.size.width;
    centre.y=bounds.origin.y+0.5*bounds.size.height;

    // Clip context
    CGPathRef path = CGPathCreateWithEllipseInRect(bounds, NULL);
    CGContextAddPath(ctx, path);
    CGContextClip(ctx);

    // Add black outline
    path = CGPathCreateWithEllipseInRect(bounds, NULL);
    CGContextAddPath(ctx, path);
    [[UIColor blackColor] setStroke];
    CGContextSetLineWidth(ctx, 3.0);

    // Specify shadow
    CGSize offset=CGSizeMake(1,4);
    CGColorRef colour=[[UIColor darkGrayColor] CGColor];
    CGContextSetShadowWithColor(ctx, offset, 2, colour);

    // Draw image
    UIImage *littleImage=[UIImage imageNamed:@"image.png"];
    [littleImage drawInRect:bounds];

    CGContextStrokePath(ctx);

}

Thanks for reading.

  • 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-06-17T08:47:43+00:00Added an answer on June 17, 2026 at 8:47 am

    OK, there were a couple things that needed doing to fix this. I think that this code could likely be reduced by a few lines, but here’s what worked:

    -(void)drawRect:(CGRect)dirtyRect{
        CGContextRef ctx=UIGraphicsGetCurrentContext();
    
        // Create bounds and path for rectangle slightly smaller than view (Thanks, Andrew T., for this!)
        CGRect bounds=[self bounds];
        CGFloat smallerBy=20.0;
        CGRect smallBounds=CGRectMake(bounds.origin.x+smallerBy/2, bounds.origin.y+smallerBy/2, bounds.size.width-smallerBy, bounds.size.height-smallerBy);
        CGPathRef path = CGPathCreateWithEllipseInRect(smallBounds, NULL);
        CGContextAddPath(ctx, path);
    
        // Add black outline with shadow to bounds
        [[UIColor blackColor] setStroke];
        CGContextSetLineWidth(ctx, 5.0);
        CGSize offset=CGSizeMake(3,4);
        CGColorRef colour=[[UIColor lightGrayColor] CGColor];
        CGContextSetShadowWithColor(ctx, offset, 8, colour);
        CGContextStrokePath(ctx);
    
        // Draw opaque white circle (to cover up shadow that was leaking "inside" image)
        [[UIColor whiteColor] setFill];
        CGContextSetLineWidth(ctx, 0.0);
        CGContextFillEllipseInRect(ctx, smallBounds);
    
        // Draw shadowless black outline over white circle (the circle had bitten into the original outline)
        CGContextSetShadowWithColor(ctx, offset, 3, NULL);
        CGContextAddPath(ctx, path);
        [[UIColor blackColor] setStroke];
        CGContextSetLineWidth(ctx, 5.0);
        CGContextStrokePath(ctx);
    
        // Clip context to bounds
        CGContextAddPath(ctx, path);
        CGContextClip(ctx);
    
        // Draw image
        UIImage *newImage=[UIImage imageNamed:@"image.png"];
        [newImage drawInRect:smallBounds];
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a view passing on information from a database: def serve_article(request, id): served_article

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.