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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:43:08+00:00 2026-06-12T09:43:08+00:00

I have a ViewController with a radial gradient background. Inside that I have a

  • 0

I have a ViewController with a radial gradient background. Inside that I have a UITableView with cells and sections. Now I want to show the gradient behind the table view as you scroll. The issue is that when the section locks at the top you can see the cells behind the section. I would set the section background color but if I do that it does not match the radial gradient background. Is there anyway to have the cells clip under the sections while keeping the clearColor 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-06-12T09:43:09+00:00Added an answer on June 12, 2026 at 9:43 am

    if I understand it, you want a completely clear tableview and tableview cell so you can see the background of your view controller.

    You can achieve this by setting the tableview as having no background

    tableview.backgroundColor = [UIColor clearColor];
    tableView.opaque = NO;
    tableView.backgroundView = nil;
    

    and also the cell

    cell.backgroundColor = [UIColor clearColor]
    

    if you also want the section to be transparent, you can use this method:

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    

    to make a custom view (for example create an image view with a transparent .png for the background)

    I hope I understand your question correctly.


    edit after clarification

    to give the appearance that the cells stop before going underneath the section header:

    make a class that is a subclass of uitableview with this ivar:

    @interface CustomTableView : UITableView
    {
            CAGradientLayer* maskLayer;
    }
    

    obviously this will create a gradient but if you wanted you could either tweak it or use CALayer and instead of programmatically creating the mask, create a .png with the correct width/height of your section header.

    ANYWAY: if you use the CAGradientLayer:

    - (id)initWithCoder:(NSCoder *)coder
    {
        self = [super initWithCoder:coder];
        if (self) 
        {
            [self setupGradients]; //call your method
        }
        return self;
    }
    
    - (void)setupGradients
    {
        [self addObserver:self forKeyPath:@"contentOffset" options:0 context:nil];
    
        */ ***** if you choose to use CALayer instead of CAGradient ****** */
        //maskLayer = [[CALayer layer] retain]; 
        //maskLayer.contents = (id) [UIImage imageNamed:@"maskLayer.png"].CGImage; 
        //maskLayer.backgroundColor = [UIColor clearColor].CGColor; 
        */ ***** if you choose to use CALayer instead of CAGradient ****** */
    
        maskLayer = [[CAGradientLayer layer] retain];
    
        CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;
        CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
    
        maskLayer.colors = [NSArray arrayWithObjects:(id)outerColor, 
                            (id)innerColor, (id)innerColor, (id)outerColor, nil];
        maskLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0], 
                               [NSNumber numberWithFloat:0.0], 
                               [NSNumber numberWithFloat:0.9], 
                               [NSNumber numberWithFloat:1.0], nil]; //this creates a gradient     effect. Tweak these numbers for a hard line. 
    
        maskLayer.bounds = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        maskLayer.anchorPoint = CGPointZero;
    
        self.layer.mask = maskLayer;
        }
    
    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
    {        
        [CATransaction begin];
        [CATransaction setDisableActions:YES];
        maskLayer.position = CGPointMake(0, self.contentOffset.y);
        [CATransaction commit];
    }
    

    then in your view controller:

       CustomTableView *_tableView; //ivar
    
       _tableView = [[CustomTableView alloc] initWithFrame:YOUR_FRAME];
    

    The basic idea is a mask, you create a mask shape on the top of your tableview that is the same size as your section header. it will appear that the cells “disappear” behind it. It’s a bit tricky, but it will work.

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

Sidebar

Related Questions

I want to have a ViewController that has a table view on the top
I have a ViewController (with navigation) that needs to show 7 different content layouts
I have a viewController showing an UIWebView . Inside of that UIWebView I have
i have viewcontroller with table view that when i click on a cell i
I have ViewController(Passwordviewcontroller) which I want to show with presentModalviewController I have an AppDeleage:
I have a ViewController with a nib file and want to delegate code that
I have a viewcontroller that can show several popovers. Not at the same time.
I have a ViewController that includes its own .nib file, I am wanting to
I have a ViewController that has its own NIB. I would like to embed
I have a viewController that autorotates just fine, The problem is that is 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.