Linked Questions
41 questions linked to/from How do I make an attributed string using Swift?
17 votes
1 answer
15k views
UILabel text with different font size and color [duplicate]
Howto set different font size and color in a UILabel with Swift? I need to color the first char of the string with different color and size than the rest of the string.
1 vote
1 answer
2k views
How can I set a custom color and font size for the title of an NSButton?(in OS X NOT iOS) [duplicate]
For example consider I have a button named Button and its title is "Hello" . How can I make the title red colored with a font size of 35? Thanks for all your answers in advance!
1 vote
0 answers
128 views
Is there a simple way to make text in a variable bold in Swift? [duplicate]
Let's say this is my label: @IBOutlet weak var hello: UILabel! I have these 2 variables: let greeting = "Hello, my name is" let name = "Bob" I want to update my label, so I do this: hello.text = "\(...
318 votes
14 answers
249k views
How do you use NSAttributedString?
Multiple colours in an NSString or NSMutableStrings are not possible. So I've heard a little about the NSAttributedString which was introduced with the iPad SDK 3.2 (or around 3.2) and is available on ...
129 votes
12 answers
78k views
Detecting taps on attributed text in a UITextView in iOS
I have a UITextView which displays an NSAttributedString. This string contains words that I'd like to make tappable, such that when they are tapped I get called back so that I can perform an action. I ...
129 votes
10 answers
163k views
How to create range in Swift?
In Objective-c we create range by using NSRange NSRange range; So how to create range in Swift?
99 votes
12 answers
241k views
iPhone system font
What is the name of the default system font on the iPhone? I would like to retrieve this for customizing a UIView.
88 votes
8 answers
93k views
Swift extension example
I was originally wanting to know how to make something like this UIColor.myCustomGreen so that I could define my own colors and use them throughout my app. I had studied extensions before and I ...
48 votes
15 answers
34k views
UITableView titleForHeaderInSection shows all caps
I am using titleForHeaderInSection to show a header for a UITableView section. It worked fine with the iOS6 SDK, but the iOS7 SDK shows the header in all CAPS. I guess it's part of Apple's updated ...
48 votes
7 answers
23k views
How to apply text shadow to UITextView?
Actually I love UILabel. They're sweet. Now I had to go to UITextView because UILabel is not aligning text vertically to the top. Damn. One thing I really need is a text shadow. UILabel has it. ...
52 votes
7 answers
86k views
How to set font size on NSAttributedString
Edit - This has been marked as duplicate, but as I state below, I am looking for a Swift solution. Everything I've found is written in Objective C. I am trying to convert HTML into an ...
42 votes
9 answers
39k views
replace entire text string in NSAttributedString without modifying other attributes
I have a reference to NSAttributedString and i want to change the text of the attributed string. I guess i have to created a new NSAttributedString and update the reference with this new string. ...
20 votes
2 answers
11k views
Text change on UIButton doesn't stick
I have an UIButton in my View that says "STOP". When pressed, it should (stop the playback, of course, and) change its label to "RTN TO ZERO". This is straightforward: stopButton.titleLabel.text = @"...
13 votes
6 answers
20k views
Can't apply line spacing with UITextView? [duplicate]
Do you have any ideas about line spacing with UITextView? I cannot apply it. Below it is my code. import UIKit class DetailViewController: UIViewController { @IBOutlet weak var itemTextView: ...
19 votes
4 answers
19k views
Changing Background color on NSAttributedString
I just wanted to know how could i change the background color of an NSAttributedString, i can see the background being white all the time, but i want to make it black. Is that possible?? Many thanks!