<!--
{
  "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/setSelected(_:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITableViewCell(im)setSelected:animated:"
  },
  "title" : "setSelected(_:animated:)"
}
-->

# setSelected(_:animated:)

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

```
func setSelected(_ selected: Bool, animated: Bool)
```

## Parameters

`selected`

<doc://com.apple.documentation/documentation/Swift/true> to set the cell as selected, <doc://com.apple.documentation/documentation/Swift/false> to set it as unselected. The default is <doc://com.apple.documentation/documentation/Swift/false>.

`animated`

<doc://com.apple.documentation/documentation/Swift/true> to animate the transition between selected states, <doc://com.apple.documentation/documentation/Swift/false> to make the transition immediate.

## Discussion

The selection affects the appearance of labels, image, and background. When the selected state of a cell is <doc://com.apple.documentation/documentation/Swift/true>, it draws the background for selected cells (Reusing cells) with its title in white.

---

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)