Check Mobile App
Read now
Start a Project

Text Formatting In Swift

Save

Hello guys, today we learn about “Text Formatting In Swift”.

OverView Of Text Formatting:-

In this blog, we are going to learn about how to format the text like:- bold, italic, underline, and how can we change the text color. sometimes we need to bold, italic, or underline some word in a paragraph. so in this blog, we learn this thing one by one.

For doing text formatting we need NSAttributedString

What is NSAttributedString?

A string with associated attributes (such as visual style, hyperlinks, or accessibility data) for a portion of its text.

NSAttributedString uses with UILabel and UITextView which is accepted attribute string directly. when we write a simple string we don’t need it but sometimes we want some string characters like – bold, italic, underline and sometimes we want to change the color of some character that time we called a class knows as NSAtrributedString.

Uses:-

1. Bold:- for changing the text as bold we need .boldSystemFont

2. Italic:- for changing the text as italic we need .italicSyatemFont

3. Underline:- for changing the text as underline we need NSUnderlineStyle

4. color:- for changing the text color we need .foregroundColor: color name

Full Example:-

  1. create a UIScreen

2. code for text formatting

Output:-

Conclusion:-

In this blog, we discussed Text Formatting In Swift

I hope this blog will help you to get about text formatting

Thanks for reading !!

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home