Здесь мне нужно сделать выбранный текст строки, чтобы увеличить шрифт, изменить цвет и сделать подчеркивание, как атрибутированный текст, и это я завершил, но здесь мне нужно выделить только выбранный текст ячейки, как с указанными выше атрибутами, и когда я нажимаю на другую строку затем мне нужно, чтобы текст оставшихся ячеек был нормальным без увеличения размера шрифта, цвета и подчеркивания, а оставшиеся ячейки были обычными. Может ли кто-нибудь помочь мне, как это реализовать?


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "categoriesTableCell", for: indexPath) as! categoriesTableViewCell
if indexPath.row == currentSelection {
let item = categoriesModelClass?.childrenData[indexPath.row]
cell.categoriesProductsLabel.font = UIFont(name:"Bold", size:17)
cell.categoriesProductsLabel.textColor = UIColor.black
let underlineAttribute = [NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue]
let underlineAttributedString = NSMutableAttributedString(string: (item?.name)! , attributes: underlineAttribute)
underlineAttributedString.addAttribute(NSUnderlineColorAttributeName, value: UIColor.cyan, range: NSRange(location: 0, length: (item?.name?.characters.count)!))
cell.categoriesProductsLabel.attributedText = underlineAttributedString
}
else {
let item = categoriesModelClass?.childrenData[indexPath.row]
cell.categoriesProductsLabel.textColor = UIColor.darkGray
cell.categoriesProductsLabel.text = item?.name
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let previousSelection = self.currentSelection
self.currentSelection = indexPath.row
if previousSelection == -1 {
let index = indexPath
let cell = self.sideTableView.cellForRow(at: indexPath) as! categoriesTableViewCell
let item = categoriesModelClass?.childrenData[indexPath.row]
cell.categoriesProductsLabel.font = UIFont(name:"Bold", size:17)
cell.categoriesProductsLabel.textColor = UIColor.black
let underlineAttribute = [NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue]
let underlineAttributedString = NSMutableAttributedString(string: (item?.name)! , attributes: underlineAttribute)
underlineAttributedString.addAttribute(NSUnderlineColorAttributeName, value: UIColor.cyan, range: NSRange(location: 0, length: (item?.name?.characters.count)!))
cell.categoriesProductsLabel.attributedText = underlineAttributedString
sideTableView.reloadRows(at: [indexPath], with: .none)
}else {
let prevIndexPath = IndexPath(row: previousSelection, section: 0)
self.sideTableView.reloadRows(at: [prevIndexPath,indexPath], with: .none)
}
}
didSelectRowAt, поскольку вы перезагружаете ячейку, это повлияет автоматически - person Priya   schedule 26.12.2017