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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:53:48+00:00 2026-06-18T04:53:48+00:00

I have a tableview cell that needs to look like this: Basically I have

  • 0

I have a tableview cell that needs to look like this:

enter image description here

Basically I have a label on the left side that will always remain the same length. That is no problem. On the right side I have a label that will change in length, for instance it will contain someone’s name which obviously varies from person to person. That label needs to be right aligned on the cell, also no problem.

The problem is that on the left of the dynamic label, I want to have an static UIImage, that will be say 10 pixels from the dynamic label, but will move with it.

Thoughts?

This is the current code, the image is a subview of the label, but obviously not moving dynamically.

            // Add text label
        UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 0.0, 80.0, 45.0)];
        textLabel.backgroundColor = [UIColor clearColor];
        textLabel.text = @"Account";
        textLabel.opaque = NO;
        textLabel.textColor = [UIColor colorWithRed:143/255 green:143/255 blue:143/255 alpha:.6];
        textLabel.font = [UIFont boldSystemFontOfSize:15];
        textLabel.shadowColor = [UIColor whiteColor];
        textLabel.shadowOffset = CGSizeMake(0.0, 1.0);

        //Add the image
        UIImage *image = [UIImage imageNamed:@"image.png"];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 13.5, 18, 18)];
        [imageView image];

        // Add the Next Value label
        UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(170, 0.0, 100, 45.0)];
        valueLabel.textAlignment = UITextAlignmentRight;
        valueLabel.textColor = [UIColor colorWithRed:143/255 green:143/255 blue:143/255 alpha:.6];
        valueLabel.backgroundColor = [UIColor clearColor];
        valueLabel.opaque = NO;
        valueLabel.font = [UIFont systemFontOfSize:15];
        valueLabel.text = [[NSUserDefaults standardUserDefaults] valueForKey:@"name"];

        [cell addSubview:textLabel];
        [cell addSubview:valueLabel];
        [valueLabel imageView];

        cell.selectionStyle = UITableViewCellSelectionStyleNone;
  • 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-18T04:53:50+00:00Added an answer on June 18, 2026 at 4:53 am

    Try this code:

        // Add text label
        // same as before
        // ...
    
        NSInteger bufferFromEndOfCell = 10; // how much space you want between the end of your valueLabel and the end of the tableCell
        NSInteger widthOfValueLabel = 100; // dynamic, change this to whatever width you want
        NSInteger startingXlocationForValueLabel = tableView.frame.size.width - bufferFromEndOfCell - widthOfValueLabel;
    
        // Add the Next Value label
        UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(startingXlocationForValueLabel, 0.0, widthOfValueLabel, 45.0)];
        valueLabel.textAlignment = UITextAlignmentRight;
        valueLabel.textColor = [UIColor colorWithRed:143/255 green:143/255 blue:143/255 alpha:.6];
        valueLabel.backgroundColor = [UIColor clearColor];
        valueLabel.opaque = NO;
        valueLabel.font = [UIFont systemFontOfSize:15];
        valueLabel.text = [[NSUserDefaults standardUserDefaults] valueForKey:@"name"];
    
        //Add the image
        NSInteger widthOfImage = 18;
        NSInteger bufferBetweenImageAndLabel = 8; // the gap between your UIImageView and your valueLabel
        CGRect rectForImageView = CGRectMake(valueLabel.frame.origin.x - widthOfImage - bufferBetweenImageAndLabel, 13.5, widthOfImage, 18);
        UIImage *image = [UIImage imageNamed:@"image.png"];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:rectForImageView];
        imageView.image = image;
    
        [cell addSubview:textLabel];
        [cell addSubview:valueLabel];
        [cell addSubview:imageView];
    

    I am sure there are cleaner solutions but I just pounded this out quickly. This forces the image view to dynamically change with the right label. If this is not exactly what you are looking for let me know. I just based this on the information I had.

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

Sidebar

Related Questions

I have a custom tableview cell created programmatically that consists of: a background view
I have a dynamic tableview which has a prototype cell with a button that,
I have a UISwitchView on every tableview cell, and would like to allow the
I have a table that needs to save the title of the cell selected
I have a progress indicator in a tableview cell that does not update its
I have a tableview, one of the rows contains a cell that contains a
I'm making an app that needs three buttons in each tableview cell. I tried
I have a tableView that needs to be updated after information has been inserted
I have a table view controller with (among others) a cell that is to
On each cell of my table view I want to have a bar that

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.