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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:51:52+00:00 2026-05-28T01:51:52+00:00

I am implementing UITableViewCells that have a custom background and expands when tapped. I

  • 0

I am implementing UITableViewCells that have a custom background and expands when tapped.

I am setting a custom view as my UITableViewCells backgroundView: (in RowForIndexPath)

if (cell == nil) {
    CGRect f = CGRectMake(0.0f, 0.0f, 300.0f, 50.0f);

    cell = [[UITableViewCell alloc] initWithFrame:f reuseIdentifier:cellIdentifier];

    UIView *back = [[UIView alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 300.0f, 50.0f)];
    back.layer.cornerRadius = 8.0f;
    [back setBackgroundColor:[UIColor blackColor]];

This works fine, by setting the backgroundView instead of the contentView, my backgroundView scales to accommodate the new size of the cell after it expands (changing the height in heightForRowAtIndexPath after a tap).

My problem is now that I would like a few pixels vertical space between my cells. Using the above approach will make the rounded black cells be displayed “back to back”.

Is there a way to add the vertical space between the cells or is there a completely different approach I can take to obtain the desired look of my cells?

Thanks in advance.

  • 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-28T01:51:53+00:00Added an answer on May 28, 2026 at 1:51 am

    In order to display a space between cells and avoid the “back to back” issue that you are having you can add a UIView with the the following frame CGRectMake(0, 0, 320, 1) and the background set to a light gray for the standard cell separator or if you just want some padding you can make the background clear.

    Personally I like to use interface builder but you can of course do this programmatically.

    UIView *cellSeparator = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320 ,1)];
    [cellSeparator setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin |
                                       UIViewAutoresizingFlexibleRightMargin | 
                                       UIViewAutoresizingFlexibleWidth];       
    [cellSeparator setContentMode:UIViewContentModeTopLeft];    
    [cellSeparator setBackgroundColor:[UIColor lightGrayColor]];
    [cell addSubview:cellSeparator];
    [cellSeparator release];
    

    The reason I set the cellSeparator at the top of the cell is because the effect is really for the cells that fall in between the first and last rows. Also it is important to set the autoresizingMask and the contentMode to make sure the cell separator adjusts properly when you make size changes to the UITableViewCell. If you have any elements in the cell that start at x=0 y=0 of you will need to move them down the height of the cell separator plus perhaps some additional pixels for padding so that the separator doesn’t run through any elements with in the cell.

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

Sidebar

Related Questions

I'm trying to create a custom table view cell that has a button on
Im implementing a ZoomButtonsController in my custom View and have been trying to figure
I have a question regarding uitable view. I am implementing an app which is
I have one table view within the app that I hope multiple parts of
Implementing custom DataAnnotationsModelMetadataProvider in ASP.NET MVC2. Assuming the object that is being rendered looks
I have a UITableview with standard UITableViewCells . On selecting a cell, I would
I have some code that displays a checkmark as the auxiliary view of a
I'm implementing a UIView's (UITableViewCell to be more exact) drawRect method. My view has
When implementing Quicksort, one of the things you have to do is to choose
Implementing a custom VM and I've come to use registers (these will store pointers

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.