<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewCell/setHighlighted(_:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITableViewCell(im)setHighlighted:animated:"
  },
  "title" : "setHighlighted(_:animated:)"
}
-->

# setHighlighted(_:animated:)

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

```
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

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`](/documentation/UIKit/UITableViewCell/textLabel) (and [`detailTextLabel`](/documentation/UIKit/UITableViewCell/detailTextLabel) properties and set the label’s [`highlightedTextColor`](/documentation/UIKit/UILabel/highlightedTextColor) property; for images, get the cell’s image using the [`imageView`](/documentation/UIKit/UITableViewCell/imageView) property and set the [`UIImageView`](/documentation/UIKit/UIImageView) object’s `highlightedImage` property.

A custom table cell may override this method to make any transitory appearance changes.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)