UITableViewCell Space between Title and Subtitle -iOS

后端 未结 5 1372
[愿得一人]
[愿得一人] 2021-01-12 16:22

How can I increase the space between the title and subtitle in UITableViewCell?

\"enter

5条回答
  •  长发绾君心
    2021-01-12 17:03

    1. create a custom cell.
      1. new file->user interface-> empty
      2. name for your custom cell-> drag and drop a table view cell.
      3. now you have complete control. you can place your label anywhere.
      4. give a identifier name for your custom cell.
    2. create a class (subclass of UITableViewCell) for your custom cell.
      1. set property for your labels.
      2. synthesize property in .m
      3. make connection for your labels from IB.
    3. update your table view class.

      1. import custom cell's class.
      2. use your custom cell's identifier in cellForRowAtIndexPath.

        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        {
            static NSString *simpleTableIdentifier = YOUR CUSTOM CELL's IDENTIFIER;
        
            SimpleTableCell *cell = (SimpleTableCell *)[tableView    dequeueReusableCellWithIdentifier:simpleTableIdentifier];
            if (cell == nil)
            {
                NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
                cell = [nib objectAtIndex:0];
            }
        
        
            //configure your cell.
            cell.YOURLABEL1.text=@"YOUR TEXT FOR LABEL 1";
            cell.YOURLABEL2.text=@"YOUR TEXT FOR LABEL 2"
        
            return cell;
        }
        

    thats It.

提交回复
热议问题