Put checkmark in the left side of UITableViewCell

前端 未结 6 408
感情败类
感情败类 2020-12-23 00:14

I want to make something similar to the WiFi settings page: when you tap the table cell, put a checkbox in the left side of the cell, and have a disclosure button accessory

6条回答
  •  我在风中等你
    2020-12-23 00:40

    The answer is YES! You don't have to create a custom cell for that or add image views. To simulate checkboxes you only have to prepend a unicode symbol for a checkbox state to the cell text.

    The unicode symbols I'm using for checkboxes are \u2705 for checked and \u2B1C for unchecked (nearly the same as \U0001F533 on iOS 5). iOS renders several unicode symbols as icons.

    Here are some other symbols:

    enter image description here

    @"\u2611", @"\u2B1C", @"\u2705", @"\u26AB", @"\u26AA", @"\u2714", @"\U0001F44D", @"\U0001F44E"
    

    Imitating the Wi-Fi settings page (with UITableViewCellStyleValue1):

    enter image description here

    cell.textLabel.text = @"\u2001 Wi-Fi 1";
    cell.detailTextLabel.text = @"\U0001F512 \u268A";
    
    cell.textLabel.text = @"\u2001 Wi-Fi 2";
    cell.detailTextLabel.text = @"\U0001F512 \u268C";
    
    cell.textLabel.text = @"\u2713 Wi-Fi 3";
    cell.detailTextLabel.text = @"\U0001F513 \u2630";
    

提交回复
热议问题