
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to use Bold & Non-Bold Text In A Single UILabel in iOS/iPhone?
To use a Bold and a regular/Non-Bold text in a single UILabel, we can either use a storyboard editor to achieve the same, or we can do it programmatically. Let’s see both of them.
Method One − Editing with Storyboard
Select the label you want to edit, go to it’s attribute inspector.
From the first option Text, select Attributes instead of plain.
Write the following text in the label “Bold Regular”
Double Click on Bold to select it, and then right click on it to see more options.
Select font > Bold from that option. It should do the task.
Method Two − Programmatically Achieving the result.
Add the following code inside you View Controller’s View did load method.
override func viewDidLoad() { super.viewDidLoad() let boldAttribute = [ NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Bold", size: 18.0)! ] let regularAttribute = [ NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Light", size: 18.0)! ] let boldText = NSAttributedString(string: "Bold", attributes: boldAttribute) let regularText = NSAttributedString(string: " regular", attributes: regularAttribute) let newString = NSMutableAttributedString() newString.append(boldText) newString.append(regularText) lbl.attributedText = newString }
This code can be converted to function or extensions as per requirement. When we run with any of the above-mentioned methods the same result is produced as shown below.
- Related Articles
- How to add line break for UILabel in iOS/iPhone?
- How to make text bold in HTML?
- How to bold text in checkbox in Excel?
- How to add bold annotated text in Matplotlib?
- How to create a bold text using JavaScript?
- How to make a text bold and italic in JavaFX?
- How do we add bold text in HTML?
- How to make a specific text on TextView bold in Android?
- How to display a bold text inside the JTextArea in Java?\n
- How to Bold a Part of a Text String in a Cell in Excel?
- How to make a specific text on TextView bold in Android using Kotlin?
- How to make text bold, italic and underline using jQuery
- How To Create a Bold Makeup Look?
- How to Create a Bold Lip Makeup Look?
- How to do bold and simple text in the same line using the echo in php?

Advertisements