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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:08:36+00:00 2026-05-14T07:08:36+00:00

I am drawing content to a UITableViewCell and it is working well, but I’m

  • 0

I am drawing content to a UITableViewCell and it is working well, but I’m trying to understand if there is a better way of doing this.

Each cell has the following components:

  • Thumbnail on the left side – could come from server so it is loaded async
  • Title String – variable length so each cell could be different height
  • Timestamp String
  • Gradient background – the gradient goes from the top of the cell to the bottom and is semi-transparent so that background colors shine through with a gloss

It currently works well. The drawing occurs as follows:

  • UITableViewController inits/reuses a cell, sets needed data, and calls

    [cell setNeedsDisplay]

  • The cell has a CALayer for the thumbnail – thumbnailLayer

  • In the cell’s drawRect it draws the gradient background and the two strings

  • The cell’s drawRect it then calls setIcon – which gets the thumbnail and sets the image as the contents of the thumbnailLayer. If the image is not found locally, it sets a loading image as the contents of the thumbnailLayer and asynchronously gets the thumbnail. Once the thumbnail is received, it is reset by calling setIcon again & resets the thumbnailLayer.contents

This all currently works, but using Instruments I see that the thumbnail is compositing with the gradient. I have tried the following to fix this:

  • setting the cell’s backgroundView to a view whose drawRect would draw the gradient so that the cell’s drawRect could draw the thumbnail and using setNeedsDisplayInRect would allow me to only redraw the thumbnail after it loaded — but this resulted in the backgroundView’s drawing (gradient) covering the cell’s drawing (text).

  • I would just draw the thumbnail in the cell’s drawRect, but when setNeedsDisplay is called, drawRect will just overlap another image and the loading image may show through. I would clear the rect, but then I would have to redraw the gradient.

  • I would try to draw the gradient in a CAGradientLayer and store a reference to it, so I can quickly redraw it, but I figured I’d have to redraw the gradient if the cell’s height changes.

Any ideas? I’m sure I’m missing something so any help would be great.

Bump – anyone have any ideas for 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-05-14T07:08:37+00:00Added an answer on May 14, 2026 at 7:08 am

    I started using setNeedsDisplayInRect. I still draw everything in drawRect but when I do, I check the rect that needs to be drawn and only update that rect. I also draw using CGLayers and keep them as ivars. When I need to redraw a section that hasn’t changed, I use the stored CGLayer. The thumbnail is no longer a CALayer. For drawing selects I will have to use the selectedBackgroundView and reuse my CGLayers.

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

Sidebar

Related Questions

I am custom drawing text into a custom UITableViewCell, but am struggling in working
Windows Forms: For System.Drawing there is a way to get the font height. Font
I have read Loren's article on drawing your own content for UITableViewCell. However, he
I am trying to create a UITableViewCell which overrides the complete drawing of the
Is there a way to get a DrawingContext (or something similar) for a WriteableBitmap
System.Drawing.Color objects apparently won't serialize with XmlSerializer. What is the best way to xml
I'm working on drawing an SVG grid using Javascript. I've managed to get the
I'm doing custom drawing in datagridview cells and I have items that can vertically
Is there a System.Drawing.Image.FromHbitmap equivalent in WPF? Also, is it possible to dispose the
I'm using System.Drawing.Color, is there anything in Visual Studio that can display the color

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.