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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:00:06+00:00 2026-05-19T16:00:06+00:00

I’m working with a UITableView and a custom UITableViewCell . Initially, this had poor

  • 0

I’m working with a UITableView and a custom UITableViewCell. Initially, this had poor performance as I was loading the view for the cell from the nib file.

I have found a blog post by the author of Twitter for iPhone that discusses drawing our own graphics for cells to improve performance. This sounds easy enough, right?

So, I began doing that here:

- (void)drawRect:(CGRect)rect{
// Drawing code
#define LEFT_COLUMN_WIDTH 48

#define MIDDLE_COLUMN_OFFSET 52
#define MIDDLE_COLUMN_WIDTH 180

#define MAIN_FONT_SIZE 12
#define MIN_MAIN_FONT_SIZE 10
#define SECONDARY_FONT_SIZE 10
#define MIN_SECONDARY_FONT_SIZE 10

#define RIGHT_COLUMN_SIZE 70
#define PADDING 4

UIColor * secondaryTextColor = nil;
UIFont * secondaryFont = [UIFont systemFontOfSize:SECONDARY_FONT_SIZE];

//mainTextColor = [UIColor blackColor];
secondaryTextColor = [UIColor blackColor];
self.backgroundColor = [UIColor whiteColor];


CGPoint point;

CGSize size;

//[mainTextColor set];

NSString * textToDisplay = @"Test";

CGPoint rightColumnStart = CGPointMake(self.frame.size.width - PADDING - RIGHT_COLUMN_SIZE, 0);

point = CGPointMake(rightColumnStart.x + (RIGHT_COLUMN_SIZE/2 - size.width/2), 40);
[textToDisplay drawAtPoint:point forWidth:RIGHT_COLUMN_SIZE withFont:secondaryFont minFontSize:MIN_SECONDARY_FONT_SIZE actualFontSize:NULL lineBreakMode:UILineBreakModeTailTruncation baselineAdjustment:UIBaselineAdjustmentAlignBaselines];

    // background color
/*CGContextRef context = UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextAddRect(context, CGRectMake(rightColumnStart.x, 0, RIGHT_COLUMN_SIZE, self.frame.size.height));
CGContextFillPath(context);
 */
}

As you can see, there is a lot of stuff going on (and a fair amount of hard coding coordinates, just ignore the magic numbers for now).

So, in the code block, if you look for the comment “background color”, one can see that I’m drawing a colored rectangle. I’m also drawing text “test” within the same coordinate space that I want to show up on top of the rectangle.

So, if I run the application without the “background color” enabled, the “test” text shows up without issue. It is black, size 10, looks great, is positioned correctly, etc.

When I draw the rectangle, the “test” text does not show up. It is likely being rendered behind the colored rectangle, or the blending is not being set-up correctly.

How do I avoid this issue and blend the two together so the black text shows up on top of the colored rectangle? I’m not sure what question I should be asking through Google, so I apologize if this is very simple.

Thanks!!!!

  • 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-19T16:00:06+00:00Added an answer on May 19, 2026 at 4:00 pm

    Draw the background first and then the text on top of it.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build

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.