---
title: "setHighlighted(_:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitableviewcell/sethighlighted(_:animated:)"
---

# setHighlighted(_:animated:)

Sets the highlighted state of the cell, optionally animating the transition between states.

## Declaration

```swift
func setHighlighted(_ highlighted: Bool, animated: Bool)
```

## Parameters

- `highlighted`: doc://com.apple.documentation/documentation/Swift/true to set the cell as highlighted, doc://com.apple.documentation/documentation/Swift/false to set it as unhighlighted. The default is doc://com.apple.documentation/documentation/Swift/false.
- `animated`: doc://com.apple.documentation/documentation/Swift/true to animate the transition between highlighted states, doc://com.apple.documentation/documentation/Swift/false to make the transition immediate.

## Discussion

Discussion Highlights or unhighlights the cell, animating the transition between regular and highlighted state if animated is YES.  Highlighting affects the appearance of the cell’s labels, image, and background. Note that for highlighting to work properly, you must fetch the cell’s label (or labels) using the textLabel (and detailTextLabel properties and set the label’s highlightedTextColor property; for images, get the cell’s image using the imageView property and set the UIImageView object’s highlightedImage property. A custom table cell may override this method to make any transitory appearance changes.

## See Also

### Managing cell selection and highlighting

- [selectionStyle](uikit/uitableviewcell/selectionstyle-swift.property.md)
- [UITableViewCell.SelectionStyle](uikit/uitableviewcell/selectionstyle-swift.enum.md)
- [isSelected](uikit/uitableviewcell/isselected.md)
- [setSelected(_:animated:)](uikit/uitableviewcell/setselected(_:animated:).md)
- [isHighlighted](uikit/uitableviewcell/ishighlighted.md)
