Home Strikethrough UITableView cell text after cell containing String
Reply: 0

Strikethrough UITableView cell text after cell containing String

user1189 Published in July 23, 2018, 3:53 am

I'd like to strikethrough all cell text in UITableView after a specific line of text.

Example (after "+")

I think I'm close, but the strikethrough isn't applied in the Simulator. (build is successful)

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")

   if indexPath.row > dailyTasks.index(of: "+")! {

    let attributeString: NSMutableAttributedString =  NSMutableAttributedString(string: dailyTasks[indexPath.row])
    attributeString.addAttribute(NSAttributedStringKey.strikethroughStyle, value: 1, range: NSMakeRange(0, attributeString.length))

    cell.textLabel?.attributedText = attributeString

   } else {
     cell.textLabel?.text = dailyTasks[indexPath.row]

    cell.textLabel?.font = UIFont(name: "GillSans-Light", size: 17)
    cell.indentationLevel = 1
    cell.backgroundColor = UIColor(red:0.99, green:0.97, blue:0.91, alpha:1.0)
    cell.selectionStyle = UITableViewCellSelectionStyle.none

    return cell

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308388 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO