Questions tagged [uilabel]

The UILabel class implements a read-only text view in iOS. You can use this class to draw one or multiple lines of static text, such as those you might use to identify other parts of your user interface. The base UILabel class provides support for both simple and complex styling of the label text. You can also control over aspects of appearance, such as whether the label uses a shadow or draws with a highlight.

The UILabel class implements a read-only text view. You can use this class to draw one or multiple lines of static text, such as those you might use to identify other parts of your user interface. The base UILabel class provides support for both simple and complex styling of the label text. You can also control over aspects of appearance, such as whether the label uses a shadow or draws with a highlight. If needed, you can customize the appearance of your text further by subclassing.

The default content mode of the UILabel class is UIViewContentModeRedraw. This mode causes the view to redraw its contents every time its bounding rectangle changes. You can change this mode by modifying the inherited contentMode property of the class.

New label objects are configured to disregard user events and clip subviews by default. If you want to handle events in a custom subclass of UILabel, you must explicitly change the value of the userInteractionEnabled property to YES after initializing the object. If you want to allow subviews to extend beyond the bounds of a label, you must explicitly change the value of the label’s clipsToBounds property to NO.

For information about basic view behaviors, see View Programming Guide for iOS.

For more information about appearance and behavior configuration, see Labels in UIKit User Interface Catalog.

7081 questions
2
votes
2 answers

Auto-layout issue with stack view and label's font size

I really wanted to figure this out by myself but it's been 3 hours now and I don't think this kind of problem is worth half that amount of time so here I am seeking for help. This is an auto-layout problem so I will try my best to illustrate it…
Wizzardzz
  • 781
  • 1
  • 9
  • 32
2
votes
1 answer

UILabel not working with NSAttributedString + NSParagraphStyle for Right-To-Left

I'm having problems with UILabels that use NSAttributedStrings with NSParagraphStyle when I use UISemanticContentAttributeForceRightToLeft. I have a demo app with just 2 labels on the UI. They have leading and trailing constraints. I'm making the…
miguel.gazela
  • 143
  • 2
  • 14
2
votes
1 answer

iOS Label prevent words from being broken up into 2 lines

I want to allow multiple lines of text for activities with multiple spaced words, but adjust to fit width on single word activities, currently, this is what is happening as a result of this code: UILabel *label=[[UILabel alloc] init]; …
2
votes
0 answers

How to display dynamic multiple label in tableview cell swift?

I'm trying with NSMutableAttributedString but not getting perfect resolution and also underline for each string. Now It's display like this: But I want like this: I m trying with this code in tableView(_ tableView: UITableView, cellForRowAt…
Pankaj
  • 25
  • 4
2
votes
1 answer

UILabel size change doesn't animate with auto layout

I have an dynamic-width UILabel (colored lime-green for visibility) which has a fixed leading and trailing constraint to its neighbours (the green and red views). I want this table to adapt its width when one of its neighbours is moved (the rounded…
pajevic
  • 4,607
  • 4
  • 39
  • 73
2
votes
3 answers

How to add empty space in UILabel text

I would like to add a white space in front of any given text of a UILabel. I thought that I could extend the UILabel-class as follows: class UILabel_iKK: UILabel { override var text: String? { didSet { if let txt = self.text…
iKK
  • 6,394
  • 10
  • 58
  • 131
2
votes
0 answers

Emoji on UILabel with vibrancy not readable

I've set up a simple UIVisualEffectView with UILabel inside the vibrancy content view. The vibrancy does work for the regular text, but it makes the Emoji unreadable. Sample: Any Idea on how to fix this?
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
2
votes
1 answer

iPad/iPhone - Set the label size that fits in the given rect

In my ipad application, i've a lable that occupies whole view. I want to dynamically calculate the size of the label that fits in the whole rect. But I want to maintain the word wrap. In my XIB, I added a label and set it mode to word wrap mode.…
Satyam
  • 15,493
  • 31
  • 131
  • 244
2
votes
1 answer

label having sizeToFits() goes out of bounds

I have a tableview in where each cell has a label. The datasource of this label is from the firebase api. Now, initially the label is loaded in a perfect form. As you scroll through and if any label is of a shorter text width, the rest of the cell,…
Aakash Dave
  • 866
  • 1
  • 15
  • 30
2
votes
4 answers

How can I make a clickable UILabel in Swift 3?

I'm trying to make a clickable UILabel by following this code: class ViewNotificationsDetails: UIViewController { @IBOutlet weak var back: UILabel! override func viewDidLoad() { super.viewDidLoad() let tap =…
NelbeDG
  • 425
  • 1
  • 7
  • 19
2
votes
0 answers

UILabel in UIStackView in UITableViewCell with numberOfLines = 0

I have a UITableViewCell, with an UIImageView and a UILabel, inside a UIStackView. I want the distribution for the UIStackView to fillProportionally. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->…
nouatzi
  • 735
  • 4
  • 14
2
votes
2 answers

UILabel text doesn't appear when using ARKit

I'm programmatically generating a set of UILabels, attaching them to SCNNodes and then placing them in a scene. The problem is that the text on some of the labels doesn't appear. This occurs (seemingly) randomly. Here's the code: var labels =…
Jordan
  • 481
  • 4
  • 14
2
votes
1 answer

How to find the frame of substring inside a UILabel in swift 4?

I have a UILabel which contains some string as "I agree to below Terms & Condistions" . Now on click of "Terms & conditions" i want to get it's frame so that i can add a button on that position at run time to detect the touch on particular word.…
TechChain
  • 8,404
  • 29
  • 103
  • 228
2
votes
1 answer

Text padding on UILabel

Here, I am trying to have a label with some padding (left, right, top and bottom) around the text. This issue has related post on SOF and after reading a few of them, I tried using a solution proposed here: This is the code for my subclassing…
Michel
  • 10,303
  • 17
  • 82
  • 179
2
votes
1 answer

IOS 11 UILabel automatic line break doesn't work when text is too long

All automatic line break of UILabel was failed when I updated the XCode to 9.1. Any body same as me? I have set the attribute like below: cell.testLabel.text = "long text here" cell.testLabel.lineBreakMode =…
kaon wong
  • 21
  • 2
1 2 3
99
100