Partially Bold Text in UILabel
If you just want the names to appear in bold, use the UILabel
attributedText
attribute to set an attributed string instead of a plain text string.
Something like:
let name = names[indexPath.row]
let color = colors[indexPath.row]
let attributedText = NSMutableAttributedString(string: name, attributes:[NSFontAttributeName : UIFont.boldSystemFont(ofSize:15)])
attributedText.append(NSAttributedString(string:color))
cell.info.attributedText = attributedText
Of course, you'd need to set the font in the above for the bold part according to how you have the cell styled.
How to format some text as bold within a UILabel?
Use the attributedText
property:
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"This is a test."];
[text addAttribute:NSFontAttributeName
value:[UIFont boldSystemFontOfSize:12]
range:NSMakeRange(0, 4)];
label.attributedText = text;
Swift: Programmatically make UILabel bold without changing its size?
Why not just:
titleLabel.font = UIFont.boldSystemFont(ofSize: titleLabel.font.pointSize)
How do I remove bold from a UILabel text in Objective-C?
You can use the systemFontOfSize
method on UIFont.
cell.title.font=[UIFont systemFontOfSize:self.textFontSize];
Setting UILabel to bold?
Have you added the Custom Font to your project? If not you can do so by following this link to Apple's documentation : Adding a Custom Font to your App
You have to make sure the font file is a target member of your app; otherwise, the font file will not be distributed as part of your app.
To find the font names available to your app, do this:
for family in UIFont.familyNames.sorted() {
let names = UIFont.fontNames(forFamilyName: family)
print("Family: \(family) Font names: \(names)")
}
Related Topics
How to Check If a String Contains Another String in Objective-C
Ios 8 Uitableview Separator Inset 0 Not Working
Uiscrollview Scrollable Content Size Ambiguity
How to Have Stored Properties in Swift, the Same Way I Had on Objective-C
How to Preserve Identifierforvendor in iOS After Uninstalling iOS App on Device
Swiftui Update Navigation Bar Title Color
How to Change the Status Bar Background Color and Text Color on iOS 7
Swift Language Nsclassfromstring
How to Group by the Elements of an Array in Swift
Conditional Binding: If Let Error - Initializer For Conditional Binding Must Have Optional Type
Having a Uitextfield in a Uitableviewcell
Creating a Left-Arrow Button (Like Uinavigationbar'S "Back" Style) on a Uitoolbar
Ios 7: Uitableview Shows Under Status Bar
Cell Spacing in Uicollectionview
Getting and Setting Cursor Position of Uitextfield and Uitextview in Swift