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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:41:00+00:00 2026-05-13T17:41:00+00:00

I am trying to set up a table view with a background that scrolls.

  • 0

I am trying to set up a table view with a background that scrolls. The background is a repeating cloud image.

As a preliminary attempt to implement this, I have used the following code:

- (void)viewDidLoad {
    aTableView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"cloud.jpg"]];
    aTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

However, this does not quite work as I had hoped. The image is placed as the background to every cell (which is fine) but also as the background to the table view, so that when the user scrolls past the bounds of the screen and the bounce is used, the same cloud background is shown. This gives an undesired overlapping effect.

What I would like is for every cell to have this repeating image (so that it scrolls with the table), but for the background to the table view to be a plain black colour. Is this possible?

I know that I can add an image to the custom cell and send it to the back, but this seems like too much of a memory hogging workaround.

Cheers


I have managed to sort this using the following code:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        [cell setBackgroundColor:[UIColor colorWithPatternImage: [UIImage imageNamed: @"cloud.jpg"]]];
}

Is this the best way to set a UIColor as a UIImage or is this resource intensive?

  • 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-13T17:41:01+00:00Added an answer on May 13, 2026 at 5:41 pm

    I’ve had exactly the same problem, except half way through implementation we decided to scrap the design and went for custom tableview cells instead. Our original design was meant to look like a notepad, with cells on each line.

    Subclassing a UITableViewCell might seem like a difficult task but its worth it if you will need to customise the cell in the future and seems like it will do what you are requesting. I can post the code for you from my project if you are interested, However, be aware that you will not have the background on the UITableView itself, only on the cells.

    EDIT: Posting the code related to creation of custom UITableViewCell:
    My cell is called HotOffersCell,
    This is HotOffersCell.h

    #import <UIKit/UIKit.h>
    @interface HotOffersCell : UITableViewCell {
        IBOutlet UILabel *mainLabel;
        IBOutlet UILabel *subLabel;
        IBOutlet UILabel *price;
        IBOutlet UIImageView *imageView;
    }
    @property (nonatomic, retain) UILabel *mainLabel;
    @property (nonatomic, retain) UILabel *subLabel;
    @property (nonatomic, retain) UILabel *price;
    @property (nonatomic, retain) UIImageView *imageView;
    
    @end
    

    HotOffersCell.m is very plain, just sysnthesize for all the properties, nothing else
    Then in the TableView method of your table view controller:

    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        static NSString *CellIdentifier = @"HotOffersCell";
    
        HotOffersCell *cell = (HotOffersCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"HotOffersCell" owner:nil options:nil];
            for (id currentObject in topLevelObjects) {
                if ([currentObject isKindOfClass:[UITableViewCell class]]) {
                    cell = (HotOffersCell *) currentObject;
                    break;
                }
            }
        }
        NewsItem *newsItem = [newsList objectAtIndex:indexPath.row];
    
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"d MMM YY"];
        NSString *date = [formatter stringFromDate:newsItem.departure_date];
        if (indexPath.row % 2 == 0) {
            cell.contentView.backgroundColor = [UIColor colorWithWhite:230.0/255 alpha:1]; // Match Colour
        } else {
            cell.contentView.backgroundColor = [UIColor colorWithWhite:242.0/255 alpha:1]; // Match Colour
        }
    
        cell.mainLabel.text = newsItem.destination;
        cell.subLabel.text = [[NSString alloc] initWithFormat:@"%@ - %@ nights", date, newsItem.nights];
        if ([self.navigationController.title isEqualToString:@"Top 20"]) {
            cell.price.text = newsItem.price_inside;
        } else {
            cell.price.text = newsItem.price_balcony;
        }
        cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", newsItem.cruise_line]];
    
        [formatter release];        
        return cell;
    }
    

    I also have a HotOffersCell.xib, This file contains a UITableViewCell and no view, i’ve linked all the relevant labels around and nothing more, It provides a nice graphical way to edit the placements on the label without changes in code, I even let my brother modify this one =)

    I hope this helps

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

Sidebar

Related Questions

I'm trying to set a Table View Cell that has been grouped, as a
I'm trying to set the background image for a UITableViewController. I've got the following
I'm trying to convert this app i have from iPhone to iPad.. i've set
I'm trying to look for all addresses in a table view, that belong to
I'm trying to set the position of a table view on the screen, i
I'm trying to set the image for the cell in a tableview by code.
Im trying set the single table inheritance model type in a form. So i
I'm trying to set my entirely table row as an anchor. I've read here
I am trying to set up a table where initially all cells are empty,
The first row in my table has three cells. I'm trying to set up

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.