开发者

What is the difference between a highlighted UITableViewCell and a selected UITableViewCell?

开发者 https://www.devze.com 2022-12-27 10:21 出处:网络
A UITableViewCell reflects two distinct states: Highlighted and Selected. For me, they开发者_运维技巧 sound identical so what exactly are the differences?Highlight happens on touch down.

A UITableViewCell reflects two distinct states: Highlighted and Selected.

For me, they开发者_运维技巧 sound identical so what exactly are the differences?


Highlight happens on touch down.

Selected happens on touch up, followed by the call to didSelectRowAtIndexPath:. In a standard UITableView, there is usually a small delay between the highlight and the select.


From appearance point of view:

Selected Cell:

The selection affects the appearance of labels, image, and background. When the selected state of a cell is set to YES, it draws the background for selected cells with its title in white.

The background will be drawn based on selectionStyle & selectedBackgroundView values. I could not really see any white titles as Apple documentation mentioned. I just see the background changes as expected.

Highlighted Cell:

The highlighting affects the appearance of labels, image, and background. When the highlighted state of a cell is set to YES, labels are drawn in their highlighted text color (default is white). Note that for highlighting to work properly, you must fetch the cell’s labels using the textLabel and detailTextLabel properties and set each label’s highlightedTextColor property; for images, get the cell’s image using the imageView property and set the UIImageView object’s highlightedImage property.

Again I don't really that see that the default highlighted text color is white.

So I conclude that selected cell appearance affects the background of the cell while the highlighted cell affects the labels text colors as well as the image (if highlightedImage property is set)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号