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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:26:48+00:00 2026-05-26T19:26:48+00:00

I have a subclassed UIView loaded from a nib, and I cannot get a

  • 0

I have a subclassed UIView loaded from a nib, and I cannot get a shadow to draw around it. I’m trying to get a shadow to appear around the entire view for quite some time now. I elected to place it in it’s own sublayer to simplify animating it later. Here’s the code:

-(void)awakeFromNib 
{
    self.clipsToBounds = NO;

    // set up the shadow layer
    CALayer *shadow = [CALayer layer];
    shadow.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.bounds.size.width, self.bounds.size.height);
    shadow.shadowColor = [UIColor blueColor].CGColor;
    shadow.shadowRadius = 15.0;
    shadow.opacity = 1.0;
    [self.layer addSublayer:shadow];
    // I set this property so I have access to it later to more easily animate it.
    self.shadowLayer = shadow;
}

When I NSLog the shadowLayer property, the coordinates and frame are correct. It’s matches the view it’s backing.

I also set a border color and corner radius on self.layer and it appears correctly. If I put the shadow on self.layer it appears but it encompasses all the subviews of my parent UIView.

Any help is greatly appreciated.

  • 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-26T19:26:48+00:00Added an answer on May 26, 2026 at 7:26 pm

    Am assuming you have QuartzCore imported. I think you need to set & create a border to the UIView. The way to use this [self roundedLayerWithShadow:yourView.layer radius:5.0f];

    - (void)roundedLayerWithShadow:(CALayer *)viewLayer 
                            radius:(float)r 
    {
        [viewLayer setMasksToBounds:YES];
        [viewLayer setCornerRadius:r];        
        [viewLayer setBorderColor:[RGB(180, 180, 180) CGColor]];
        [viewLayer setBorderWidth:1.0f];
    
        [viewLayer setShadowColor:[RGB(0, 0, 0) CGColor]];
        [viewLayer setShadowOffset:CGSizeMake(0, 0)];
        [viewLayer setShadowOpacity:1];
        [viewLayer setShadowRadius:2.0];
        return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a single iPhone screen with its view loaded from
I have a Card class subclassed from UIView and a Deck class from NSObject.
I have been trying desperately to draw some images into a view. The view
I'm trying to replace a UIViewController root view with a subclassed UIView. In the
I have subclassed UIView and created a NIB that controls the main logic for
I'm a bit lost here. I have a class subclassed from UIView called BalloonGuy.
I have a custom UIView which gets loaded through a NIB inside a UIViewController.
I have subclassed UIView, but I need to prevent the frame from changing, so
I have subclassed UIView so I can draw some lines in it. In this
I have subclassed UIView object inside a uiscrollview which displays a pdf page. I

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.