UITableView separator line disappears when selecting cells in iOS7

后端 未结 24 2063
耶瑟儿~
耶瑟儿~ 2020-12-05 04:01

In my tableView I set a separator line between cells. I am allowing selection of multiple cells. Here\'s my code for setting selected cell background color:

         


        
24条回答
  •  失恋的感觉
    2020-12-05 04:42

    What I did was this:

    1. Add a new subview under the content view of the cell.
    2. Connect that from the cell as the selectedBackgroundView.
    3. Add a subview of the new selected background view. Set it to start 16px from the left and cover the rest of the width, be 1px high, 1px down from the top and have a background color of 90% white.

    In my case, I didn't want my rows shaded at all when selected, so I left the selected background view clear, but you can make it whatever color you like.

    Also, I am not using autolayout, so just set my sizes appropriately. I presume with autolayout you would have to set up appropriate constraints.

    For me, this completely resolved the problem (though I agree that this really does seem to be a bug in ios 7).

提交回复
热议问题