I'm working with TableView and I was hoping to add a background colour to a selected cell's text. Something like this:
The image represents a cell, the background color is separated. This is what is needed.
I tried doing the following but it adds a background colour to the entire cell or to the text only.
The separation between is the most important, adding a backgroundColor applys a color to the entire cell, which is not wanted.
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { //Highlighting text - Add saving text
let cell = tableView.cellForRow(at: indexPath)
print("You selected cell number: \(indexPath.row)!")
cell?.textLabel?.textColor = .yellow
cell?.textLabel?.backgroundColor = .yellow // Is not desired outcome
}