Мне все равно нужно получить стиль кода в UITableView.
Просто сделать синий фон
var dynamicBackground = #colorLiteral(red: 0.02708261088, green: 0.4768417478, blue: 0.9985074401, alpha: 1)
Затем создайте NSMutableAttributedString в UITableView.
let attr = NSMutableAttributedString(string: "if ", attributes: [.foregroundColor: KeyboardSyntax])
attr.append(NSAttributedString(string: " false condition ", attributes: [.backgroundColor: dynamicBackground])). // Any idea to make background to round corner?
attr.append(NSAttributedString(string: " {\n ", attributes: [.foregroundColor: PlainSyntax]))
attr.append(NSAttributedString(string: "// Not execute\n", attributes: [.foregroundColor: CommentSyntax]))
attr.append(NSAttributedString(string: "} ", attributes: [.foregroundColor: PlainSyntax]))
attr.append(NSAttributedString(string: "else ", attributes: [.foregroundColor: KeyboardSyntax]))
attr.append(NSAttributedString(string: "{\n ", attributes: [.foregroundColor: PlainSyntax]))
attr.append(NSAttributedString(string: "// Execute\n", attributes: [.foregroundColor: CommentSyntax]))
attr.append(NSAttributedString(string: "} ", attributes: [.foregroundColor: PlainSyntax]))
cell.textLabel?.attributedText = attr
Спасибо за вашу помощь. :)