title: How to change UILabel font size corresponding to uitabelviewcell frame when working with self sizing cells?
body: <p>I have done functionality to select address from list of available addresses. In this demo, for table view, I created custom cell which automatically adjusted for text inside UILabel (i.e. address field)</p>
  
  <p>Problem is that When the table view is first displayed, I found font size of "address label" in cells is not sized properly. But when I scroll the table view, then cells are displayed with correct font size.</p>
  
  <p><strong><em>see below images:</em></strong></p>
  
  <p><strong>Problem</strong></p>
  
  <p><a href="https://i.stack.imgur.com/j6uc3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j6uc3.png" alt="enter image description here"></a></p>
  
  <p><strong>What I want</strong></p>
  
  <p><a href="https://i.stack.imgur.com/8QcYx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8QcYx.png" alt="enter image description here"></a></p>
  
  <p>I get second behaviour after reloading tableview inside viewDidAppear. But it flickering my screen. Please help. Any help appreciated.</p>
  
  <p><strong>my code</strong></p>
  
  <p><strong>view controller.m</strong></p>
  
  <pre><code>#import "AddressListViewController.h"
  #import "AddressListTableViewCell.h"
  #import "Utils.h"
  
  @interface AddressListViewController () &lt;UITableViewDataSource, UITableViewDelegate&gt;
  
  @property (weak, nonatomic) IBOutlet UITableView *addressListTableView;
  @property (strong, nonatomic) NSArray *arraySavedAddresses;
  @property (strong, nonatomic) NSMutableParagraphStyle *paragraphStyle;
  
  @end
  
  @implementation AddressListViewController
  
  #pragma mark - lazy instantiation
  
  - (NSArray *)arraySavedAddresses {
      if (!_arraySavedAddresses)
          _arraySavedAddresses = @[@"Studio 103, The Business Centre, 61 Wellfield Road, Roath, Cardiff, CF24 3DG",
                                   @"Castor Richardson, P.O. Box 902 3472 Ullamcorper Street, Lynchburg DC 29738, (268) 442-2428, Mob. 9999999999",
                                   @"Maharashtra India",
                                   @"Office 33, 27 Colmore Row, Birmingham, England, B3 2EW"];
      return _arraySavedAddresses;
  }
  
  - (NSMutableParagraphStyle *)paragraphStyle {
      if (!_paragraphStyle) {
          _paragraphStyle = [[NSMutableParagraphStyle alloc] init];
          [_paragraphStyle setAlignment:NSTextAlignmentLeft];
          [_paragraphStyle setLineSpacing:5.0f];
      }
      return _paragraphStyle;
  }
  
  #pragma mark - view controllers life cycle methods
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      [self.view layoutIfNeeded];
  
      [self.addressListTableView setDataSource:self];
      [self.addressListTableView setDelegate:self];
  
      [self.addressListTableView setEstimatedRowHeight:80];
  }
  
  #pragma mark - table view delegate methods
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [self.arraySavedAddresses count];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      AddressListTableViewCell *addressListTableViewCell = [tableView dequeueReusableCellWithIdentifier:@"AddressListTableViewCell" forIndexPath:indexPath];
  
      [Utils updateLabelFontSize:addressListTableViewCell.labelUsername ForInitialHeight:24 andInitialSize:24];
      [addressListTableViewCell.labelAddress setFont:[addressListTableViewCell.labelAddress.font fontWithSize:[addressListTableViewCell.labelUsername bounds].size.height * 0.666667]];
  
      [addressListTableViewCell.labelUsername setText:@"Demo User"];
  
      NSString *labelText = [self.arraySavedAddresses objectAtIndex:[indexPath row]];
      NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
      [attributedString addAttribute:NSParagraphStyleAttributeName value:self.paragraphStyle range:NSMakeRange(0, [labelText length])];
      [addressListTableViewCell.labelAddress setAttributedText:attributedString];
  
      return addressListTableViewCell;
  }
  
  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
      return UITableViewAutomaticDimension;
  }
  
  @end
  </code></pre>
  
  <p><strong>tableviewcell.m</strong></p>
  
  <pre><code>#import "AddressListTableViewCell.h"
  #import "Utils.h"
  
  @implementation AddressListTableViewCell
  
  - (void)awakeFromNib {
      [super awakeFromNib];
  
      [[self.viewAddressInfo layer] setBorderColor:[[UIColor lightGrayColor] CGColor]];
  }
  
  - (void)layoutSubviews {
      [super layoutSubviews];
  
  }
  
  - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
      [super setSelected:selected animated:animated];
  
      // Configure the view for the selected state
  }
  
  - (IBAction)buttonRemoveAddressAction:(id)sender {
      NSLog(@"Cancel Pressed");
  }
  </code></pre>
  
  <p><strong>tableviewcell.h</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface AddressListTableViewCell : UITableViewCell
  
  @property (weak, nonatomic) IBOutlet UIView *viewAddressInfo;
  @property (weak, nonatomic) IBOutlet UILabel *labelUsername;
  @property (weak, nonatomic) IBOutlet UILabel *labelAddress;
  @property (weak, nonatomic) IBOutlet UIImageView *imageViewRadioSelection;
  
  @end
  </code></pre>