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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:27:08+00:00 2026-06-02T13:27:08+00:00

I’ve read and tried a few answers I have found on StackOverflow. I’ve also

  • 0

I’ve read and tried a few answers I have found on StackOverflow. I’ve also read and tried a few things from blogs, but nothing seems to accomplish what I am looking for.

I create a UIView and set it’s background color to my desired UITableViewCell selection color (instead of the standard blue or gray selection colors). I add this UIView to my cell’s selectedBackgroundView and this works fine, my cell changes to the desired color on user selection.

This method works great on Plain UITableViews; not so well on Grouped. On a grouped UITableView, the 1st and last cell do not conform to clip / mask bounds as demonstrated in the below screenshots.

I know there is no way to round just the top-left and top-right corners only.

I want to do this strictly by code, without images.

Question

Does anyone know of a nice little work around to change the selectedBackgroundView color of a UITableViewCell using only the UIView and not images AND to make the 1st and last cell conform to the rounded corner boundaries?

Example

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * CellIdentifier = @"Cell";
    WCSBadgedCell   * cell = [[WCSBadgedCell alloc] initWithStyle:UITableViewCellStyleSubtitle andBadgeStyle:0 reuseIdentifier:CellIdentifier]; 
    if (cell == nil) {
        cell = [[WCSBadgedCell alloc] initWithStyle:UITableViewCellStyleDefault andBadgeStyle:0 reuseIdentifier:CellIdentifier];
    }

    UIView *bgColorView = [[UIView alloc] init];
    [bgColorView setBackgroundColor:DARKBROWN];
    [bgColorView setClipsToBounds: YES];
    [cell.layer setMasksToBounds:YES];
    [cell setSelectedBackgroundView:bgColorView];

    [cell.textLabel setText: @"Testing a Cell"];

    return cell;
}

Screenshots

enter image description here

enter image description here

enter image description here

Solution

I Accepted CodaFis answer because he added a comment which pointed to a pretty nice (yet lengthy) solution. I had to do quite a bit of revamping, but in the end, I now have the selectedBackgroundView’s I needed which round the corners on the 1st and last cells, thanks again!

Here is a n example of how I achieved this.

  • 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-02T13:27:09+00:00Added an answer on June 2, 2026 at 1:27 pm

    I assume that you are using a UITableViewCell subclass because of the complexity of your cell. This is how I’ve been doing it:

    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]))
        {
            self.clipsToBounds = YES;
    
            UIView* bgView = [[UIView alloc] init];
            bgView.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.25f];
            self.selectedBackgroundView = bgView;
                    //other code
    
        }
        return self;
    }
    

    This produces a sort of dark grey overlay on the cell, not images required!

    In your case, the exact color of your selected cell (thanks to the handy dandy Digital Color Meter) would be

    [UIColor colorWithRed:106.0f/255.0f green:51.0f/255.0f blue:6.0f/255.0f alpha:1.0f];
    

    and the white text would be

    - (void)setSelected:(BOOL)sel animated:(BOOL)animated
    {
        [super setSelected:sel animated:animated];
    
        if (sel)
        {
            self.textLabel.textColor = [UIColor whiteColor];
    
            }
        else
        {
            self.textLabel.textColor = [UIColor colorWithRed:(105.f/255.f) green:(50.f/255.f) blue:(6.f/255.f) alpha:1.f];  
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.