iOS developers - to add a dash UITableViewCell

Original Address :: https://www.cnblogs.com/feiling/p/4789097.html

related articles

1, iOS development set top grid line dividing UITableViewCell display ---- https://blog.csdn.net/w15117957952/article/details/76854090

 

During the development process often encountered in the design drafts Cell division line style and the system comes with very different styles, how do here under the summary, including the following two steps:

 

1. Cancel the dividing line TableView default style

1

_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

 

2. Add background image for TableViewCell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = (UITableViewCell *)[_tableView dequeueReusableCellWithIdentifier:CellIdentifier];

     

    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];

        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

        // 为cell设置背景图片,是一张的上下横线,中间空白的背景图片

        cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage resizedImage:@"exitGroupButton.png"]];

    }

     

    cell.imageView.image = [UIImage imageNamed:@"[email protected]"];

    cell.textLabel.text = @"设置";

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;

}

1

exitGroupButton.png:

1

<br><br>

Published 136 original articles · won praise 306 · Views 4.37 million +

Guess you like

Origin blog.csdn.net/xqhrs232/article/details/90668591