I'm creating iOS app that has a label. I want to set two colors. One for first part and other color for remaining part.
I've seen some messages in Stack over flow that, TTTAttributedLabel has the ability to set more than one color to text. My text will be like "ABC > def". For "ABC", i want to set brown color and for "def", i want to set white color.
How can I set that?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
That searches for "def" in your string and sets the foreground color of the text to white for that range. Hope this helps. I only just learned this yesterday. Came across your question whilst trying to figure it out for myself.
You could use TTTRegexAttributedLabel available at : https://github.com/kwent/TTTRegexAttributedLabel. (TTTAttributedLabel based but more easier to use with regular expressions)