Ask coding questions

← Back to all posts
Array Element
ynaresh (0)

Hi,

How to set the array in some element thick and color change plz tell me the solution

Thanks & Regards

Commentshotnewtop
PattanAhmed (1103)

@ynaresh Hi,
Here is the code on how to make text bold using an attributed string:-

let label = UILabel()
label.attributedText =
    NSMutableAttributedString()
        .bold("\n\Hello!")

And here is the alternate for one text:-

var boldText  = "Hello!"

Now,
That was just a few examples. The main part is to fix this code into your code.
For that:-
Try your best!

With my best wishes
Hope this helps

Coder100 (8396)

You are looking for ASCII colors.

let reset = "\u{1b}[0m"
let bold = "\u{1b}[1m"
let italic = "\u{1b}[3m"
let underline = "\u{1b}[4m"
let inverse = "\u{1b}[7m"

let black = "\u{1b}[30m"
let red = "\u{1b}[31m"
let green = "\u{1b}[32m"
let yellow = "\u{1b}[33m"
let blue = "\u{1b}[34m"
let magenta = "\u{1b}[35m"
let cyan = "\u{1b}[36m"
let white = "\u{1b}[37m"
let gray = "\u{1b}[90m"
let bright_red = "\u{1b}[91m"
let bright_green = "\u{1b}[92m"
let bright_yellow = "\u{1b}[93m"
let bright_blue = "\u{1b}[94m"
let bright_magenta = "\u{1b}[95m"
let bright_cyan = "\u{1b}[96m"
let bright_white = "\u{1b}[97m"

let bg_black = "\u{1b}[40m"
let bg_red = "\u{1b}[41m"
let bg_green = "\u{1b}[42m"
let bg_yellow = "\u{1b}[43m"
let bg_blue = "\u{1b}[44m"
let bg_magenta = "\u{1b}[45m"
let bg_cyan = "\u{1b}[46m"
let bg_white = "\u{1b}[47m"
let bg_gray = "\u{1b}[100m"
let bg_bright_red = "\u{1b}[101m"
let bg_bright_green = "\u{1b}[102m"
let bg_bright_yellow = "\u{1b}[103m"
let bg_bright_blue = "\u{1b}[104m"
let bg_bright_magenta = "\u{1b}[105m"
let bg_bright_cyan = "\u{1b}[106m"
let bg_bright_white = "\u{1b}[107m"

print("\(red)red text\(reset) normal")
Coder100 (8396)

What array? What do you mean by thick and color?

ynaresh (0)

@Coder100 Suppose i have ["one", "Two", "Three", "Four",
"Five"]
in this array i want some element in Bold color