# EmphasizedString
**Repository Path**: kmyhy/emphasized-string
## Basic Information
- **Project Name**: EmphasizedString
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-04-30
- **Last Updated**: 2023-02-22
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## What's it
EmphasizeString(https://gitee.com/kmyhy/emphasized-string) is an extension that it help you to emphasize, highlight, underline, style specific sub-strings in a string. For example, given a string said 'Pls login now at www.yourdomain.com', you can make the 'www.yourdomain.com' look like an url which has an underline text-decoration with this extension.
EmphasizeString is extremely easy to use, please keep reading.
## How to use
EmphasizedString extend from String, but to be convenient, it also include 2 UIKit extension: UILabel and UITextView. Absolutely, feel free to extend it to other UIKit to take advantage of its functionality.
### UILabel extension
You can use this extension to customize your UILabel's text style:
```swift
label.text = "your special conditioner"
label.setEmphasizedText("conditioner", emphasizedFont: UIFont.boldSystemFont(ofSize: 20), emphasizedColor: UIColor.red)
```
It looks like:
Other than change text color and font, you can do more better like this:
```swift
let attributes = [
NSAttributedString.Key.underlineStyle: 1
]
label.setEmphasizedText("conditioner", emphasizedAttributes: attributes)
```
You can see that:
setEmphasizedText() method can loop through the target substring whithin whole string and emphaze every substring one by one. If you intent to emphasize just one substring instead of all found substring , you can use the setEmphasizedRange function of UILabel extension:
```swift
let string: String = "\("PRODUCT_SELECTION_YOUR_REGIME".localize()) \(name)"
lbUserName.text = string
if let font = UIFont(name: "Northwell", size: 48) {
let startIndex = string.index(string.endIndex, offsetBy: -(name.count))
let endIndex = string.endIndex
let range = startIndex..