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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:28:02+00:00 2026-05-27T21:28:02+00:00

Any ideas how to show a shadow around the grouped uitableview’s border?(around all border

  • 0

Any ideas how to show a shadow around the grouped uitableview’s border?(around all border at top, bottom, sides as well as around rounded corners of sections).

I need exactly the same effect like here on the picture:

alt

Pay attention to small shadow near the border(gray one, blue is the background)

  • 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-27T21:28:02+00:00Added an answer on May 27, 2026 at 9:28 pm

    i came up with a rather “hackish” solution to this in my opinion, so i’m not totally happy with it but anyway! the basic functionality of drawing a drop shadow around a group of cells in a section is acomplished by that. therefore i subclassed UITableView and implemented the layoutSubviews method like this:

    - (void) layoutSubviews {
        [super layoutSubviews];
    
        const CGFloat PageCellBackgroundRadius = 6.0;
    
        for(int i = 0; i < [self numberOfSections]; i++) {
            NSInteger viewTag = i + 123456;
            CGRect frameRect = [self shadowFrameForSection: i];
    
            UIView* shadowBackgroundView = [self viewWithTag: viewTag];
            if (shadowBackgroundView) {
                if (!CGRectEqualToRect(frameRect, shadowBackgroundView.frame)) {
                    shadowBackgroundView.frame = frameRect;
                    CGPathRef shadowPath = [UIBezierPath bezierPathWithRoundedRect: shadowBackgroundView.bounds 
                                                                 byRoundingCorners: UIRectCornerAllCorners
                                                                       cornerRadii: CGSizeMake(PageCellBackgroundRadius, PageCellBackgroundRadius)].CGPath;
                    shadowBackgroundView.layer.shadowPath = shadowPath;
                }
    
                [self sendSubviewToBack: shadowBackgroundView];
            } else {
                shadowBackgroundView = [[[UIView alloc] initWithFrame: frameRect] autorelease];
                shadowBackgroundView.tag = viewTag;
                shadowBackgroundView.opaque = YES;
                shadowBackgroundView.backgroundColor = [UIColor clearColor];
    
                shadowBackgroundView.layer.shadowOpacity = 0.3; 
                shadowBackgroundView.layer.shadowRadius = 2;
                shadowBackgroundView.layer.shadowColor = [[UIColor blackColor] CGColor];
                shadowBackgroundView.layer.shadowOffset = CGSizeMake(0.0, 1.0);
                CGPathRef shadowPath = [UIBezierPath bezierPathWithRoundedRect: shadowBackgroundView.bounds 
                                                             byRoundingCorners: UIRectCornerAllCorners
                                                                   cornerRadii: CGSizeMake(PageCellBackgroundRadius, PageCellBackgroundRadius)].CGPath;
                shadowBackgroundView.layer.shadowPath = shadowPath;
                shadowBackgroundView.layer.shouldRasterize = YES;
    
                [self addSubview: shadowBackgroundView];
            }
        }
    }
    

    and a little helper method:

    - (CGRect) shadowFrameForSection: (NSInteger) section {
        CGRect sectionFrame = [self rectForSection: section];
    
        CGFloat sectionHeaderHeight = CGRectGetHeight([self rectForHeaderInSection: section]);
        CGFloat sectionFooterHeight = CGRectGetHeight([self rectForFooterInSection: section]);
    
        UIEdgeInsets contentInsets = UIEdgeInsetsMake(sectionHeaderHeight + 1, 10, sectionFooterHeight + 1, 10);
        return UIEdgeInsetsInsetRect(sectionFrame, contentInsets);
    }
    

    the code is self-explanatory i think!
    basically it revolves around adding UIViews to the UITableView as subviews, for a calculated frame of a section, and then drawing the drop shadow to the layer of the added UIView. UITableView provides
    some methods for the frame calculations: “rectForSection” etc.

    i’m not happy with it because it feels not right adding views in the layoutSubviews method! (this could be done somwhere else => table view delegate?)
    i also would have liked more to work with CALayers, but you can’t tag them! because my code works by
    shrinking/expanding already added uiviews for performance reasons.

    in this form, the solution won’t work if sections disappear or if sections are reorderd etc.
    it also behaves not well if you’re adding rows in a animated fashion to the table view etc.
    but it’s quite useful for “static” grouped table views i think!

    i also haven’t tested for performance implications, so use at own risk!

    so maybe this is a good starting point for a possibly better solution to this! 🙂

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

Sidebar

Related Questions

any ideas about it? any plugin? I want find all img tag and show
Custom map is broken on satellite view, does not show satellite imagery. Any ideas,
If I have a normal input element it will show a rounded border with
Any ideas how I would hide or show a dialog tab panel depending on
Any ideas on how to implement tab completion for a .NET (C#) Console Application?
Any ideas what the average user's download speed is? I'm working on a site
Any ideas how to determine the number of active threads currently running in an
Any ideas how to display a PDF file in a WPF Windows Application? I
Any ideas on how to disable, but not uninstall Resharper 4.x or above?
Any ideas why this won't validate here: http://validator.w3.org/#validate_by_input It seems the form input tags

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.