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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:43:38+00:00 2026-06-10T07:43:38+00:00

I am trying to update the UITableViewCell view with a different type of theme.

  • 0

I am trying to update the UITableViewCell view with a different type of theme.
I have a few themes but cannot get them to work correctly.

@interface CustomRowBackground : UIView {
CGColorRef topStroke;
CGColorRef lightColor;
CGColorRef darkColor;
CGColorRef bottomStroke; //also known as separator
CGColorRef borderColor;
}

- (id)initWithFrame:(CGRect)frame topStroke:(CGColorRef)top lightColor:(CGColorRef)light   darkColor:(CGColorRef)dark bottomStroke:(CGColorRef)bottom borderColor:(CGColorRef)border;
@end

- (id)initWithFrame:(CGRect)frame topStroke:(CGColorRef)top lightColor:(CGColorRef)light    darkColor:(CGColorRef)dark bottomStroke:(CGColorRef)bottom borderColor:(CGColorRef)border
{
   self = [super initWithFrame:frame];
if (self) {
    // Initialization code
    topStroke = top;
    lightColor = light;
    darkColor = dark;
    bottomStroke = bottom;
    borderColor = border;



}
return self;
}

Now in my UIViewController, .h file, I extend the UIColor class with a helper method

@interface UIColor (BIExtras)
+(UIColor *)colorWithR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha;
@end

then in the .m I write this

@implementation UIColor (BIExtras)
+(UIColor *)colorWithR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha {
return [UIColor colorWithRed:(red/255.0) green:(green/255.0) blue:(blue/255.0) alpha:alpha];    
}
@end

then I try to set the desired gradient that I’m after for a particular row.

TaskDisplayCell *cell = (TaskDisplayCell *)[self.tableView dequeueReusableCellWithIdentifier:TaskCellIdentifier];
if (indexPath.row == 0) {
    cell.backgroundView = [[CustomRowBackground alloc]  initWithFrame:CGRectMake(0,0,self.tableView.bounds.size.width,40) 
topStroke:[UIColor colorWithR:119 G:119 B:119 A:1].CGColor 
lightColor:[UIColor colorWithR:92 G:92 B:92 A:1].CGColor 
darkColor:[UIColor colorWithR:70 G:70 B:70 A:1].CGColor 
bottomStroke:[UIColor colorWithR:76 G:76 B:76 A:1].CGColor 
borderColor:[UIColor colorWithR:110 G:110 B:110 A:1].CGColor]; 
}

Note: I am not sure if this is the way to do it. I just want to initialise the background with a different gradient theme.

Anyways, it gives me an error. If I manually write in the drawRect an assignment of a [UIColor colorWith] method, that works. If I instead allow for code reuse, it crashes.

Any ideas?

Ben

  • 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-10T07:43:39+00:00Added an answer on June 10, 2026 at 7:43 am

    One problem I see in your program is that you do not perform memory management of your CGColorRefs — ARC (assuming you have it enabled) does not manage non-ObjC objects for you. You must retain and release these manually. So in both ARC and MRC, you must retain and release these manually.

    This is the basic form:

    @interface CustomRowBackground : UIView {
        CGColorRef color;
    }
    
    - (id)initWithFrame:(CGRect)frame color:(CGColorRef)pColor;
    
    @end
    
    - (id)initWithFrame:(CGRect)frame color:(CGColorRef)pColor
    {
        self = [super initWithFrame:frame];
        if (self) {
            color = CGColorRetain(pColor);
        }
        return self;
    }
    
    - (void)dealloc
    {
        CGColorRelease(color), color = 0;
    // [super dealloc]; if MRC
    }
    
    - (CGColorRef)color
    {
        return color;
    }
    
    - (void)setColor:(CGColorRef)p
    {
        if (color == p) {
            return;
        }
        CGColorRef prev = color;
        color = CGColorRetain(p);
        CGColorRelease(prev);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to update a model on a callback but the validation is causing
When trying to update a subversion working copy from Netbeans, I get the following
i have been trying to figure this out but i just can't.... for some
I am trying to update a UITableViewCell when it is tapped for a little
Im trying to update a progress bar while doing some data type checks on
I am trying to update my DataGrid but unfortunately not able to! My application
I am trying update Pear and I type in console: pear upgrade pear then
I'm trying to update one textfield from another class: I have two classes: @interface
Trying to update a table view using: CREATE OR REPLACE VIEW [vtable] AS SELECT
In trying to update my SDK to the latest, some things installed, but others*

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.