How to control line spacing in UILabel (Swift)
Hello everyone! I'm a beginner in iOS development with Swift, and I'm having a problem with UILabel. I need the text in the label to display with increased line spacing — similar to the CSS line-height property. By default, UILabel uses standard line spacing, which looks too tight for my design.
I've tried using font attributes, but nothing works. Here's my current code:
```swift
let label = UILabel()
label.text = "This is a long text that should be displayed in multiple lines. I need more space between the lines."
label.numberOfLines = 0
label.font = UIFont.systemFont(ofSize: 16)
label.textAlignment = .left
```
I've read that I can use NSAttributedString with NSMutableParagraphStyle, but when I do that,
No answers yet.
Log in to leave an answer
Blogs
SOLID Principles in C++: Theory and Practice with Code Examples
How to Get a Job as a C++ Developer: Tips and a Resume in Practice
PHP on Servers Without Servers: AWS Lambda for Web Developers
DateTime in ISO 8601 in C#: A Complete Guide with Answers to Common Questions