Why can't you set the cell.selectionStyle = UITableViewCellSelectionStyleBlue?

后端 未结 1 1443
失恋的感觉
失恋的感觉 2020-12-21 16:19

I have seen the following questions, but non explain that while you can simply set cell.SelectedStyle to UITableViewCellSelectionStyleGray or

相关标签:
1条回答
  • 2020-12-21 16:58

    Your not going to like the answer then. As of iOS 7, setting

    cell.selectionStyle = UITableViewCellselectionStyleBlue;
    

    will now give you gray. Apple got rid of it in iOS 7, so now selectionStyleBlue no longer exists as blue.. it is gray.

    Here is the quote from Apple's Documentation of the UITableViewCell Class Reference:

    • Blue

    The cell has a default background color when selected.

    In iOS 7, the selection color is no longer blue. Use UITableViewCellSelectionStyleDefault instead.

    Available in iOS 2.0 and later.

    Of course, as I'm sure you have found, you can create a UIView and set it as the background to simulate a blue selection.

    Here is a link for that approach: UITableView cell blue highlight on selection

    Edit:

    Just to be clear. UITableViewCellSelectionStyleBlue makes the selection style gray.

    There is no default method of UITableViewCell that makes selection style a blue color.

    In order to make selection style any color other than the default gray, you have to create a custom UIView like in the link I provided.

    0 讨论(0)
提交回复
热议问题