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
1 answer

How Can I Apply a CIFilter to Part of a UILabel (or Produce the Same Visual Effect)

I need to alter specific substrings in a UILabel, using a CIFilter. A simple example might look like this: Is there a way to access and modify (i.e., use a CIFilter on) individual UILabel glyphs? Or will I need to simulate this effect by pasting…
Optimalist
  • 313
  • 2
  • 11
2
votes
1 answer

Check if text is being truncated inside UILabel or not for Read More button in swift

I want to set the number of lines property to 7 and see if my current text is all visible within the 7 lines or not. if its not then i will show a button below which will set the number of lines to 0 at the press of it. The UIlable exists inside a…
2
votes
2 answers

How to create just one tapGestureRecognizer for several UILabels?

I am trying (and failing) to create just one tapGestureRecognizer to use on several UILabels. Right now I am creating for every label in viewDidLoad a separate tapGestureRecognizer and adding it to the appropriate label. I ran into this problem…
RjC
  • 827
  • 2
  • 14
  • 33
2
votes
1 answer

UILabel dynamic height with UIImageView Constant height

In UITableViewCell i am having one imageview and two label with dynamic height and a button, i used autolayout constraints to achieve dynamic row height and expanding UILabel height, i followed this tutorial, now i want to fix the imageview height…
R. Mohan
  • 2,182
  • 17
  • 30
2
votes
3 answers

NSLineBreakByTruncatingTail not show three dots when the truncated line is end up with \n

UILabel *label label.numberOfLines = 1; label.text = @"abc\nabc"; label.lineBreakMode = NSLineBreakByTruncatingTail; display as: abc expected: abc... I've tried to set attributed text and set line break mode in paragraph attribute, did not work…
IsEE
  • 45
  • 6
2
votes
4 answers

Label background colour changed when UITableViewCell selected

I have added a custom label in UITableViewCell. Its background color is red and the font is white. When I select any cell then selected cell's label background color changed into grey. For reference, I am adding code let lblUnreadCount =…
Code Hunter
  • 10,075
  • 23
  • 72
  • 102
2
votes
2 answers

How to change detailTextLabel height programmatically

I programmed an array into a tableView. When the cell utilizes more than one line for the detailTextLabel, the space in between the lines is small. I would like to know if there is any way to increase this height programmatically? Here is sample…
Mina Makar
  • 51
  • 10
2
votes
1 answer

Embedding three UILabels in a horizontal UIStackView gives different results in a table view

For a week I have been struggling with a 'simple' piece of layout in a storyboard. I want three labels which all have numberOfLines set to two. The UIStackView has some constraints to position it in the table cell. The two left labels have a width…
2
votes
2 answers

Why Does `-[UILabel setText:]` Leak?

In a UIScrollViewDelegate class on iOS 4.2.1 in my iPad app, the -scrollViewDidEndDecelerating: method calls another method that does, this: EntryModel *entry = [entries objectAtIndex:index]; self.titleLabel.text = entry.title; title is a…
theory
  • 9,178
  • 10
  • 59
  • 129
2
votes
3 answers

Display japanese Text with furigana in UILabel

for my app, few month ago, i've take the code from this site to use CTRubyAnnotation. This code, with few changes to make work with swift 4, work perfectly. from this work I've create a class in which I written a function to use that code. this is…
Gabriele Quatela
  • 190
  • 3
  • 21
2
votes
3 answers

How to animate UILabel text size (and color)

With regard to animating the text size of UILabel, there seem to be a lot of "quick-fix" answers floating around Stack Overflow, posted by users who don't care much to understand what's happening under the hood. And for design-oriented developers,…
slider
  • 2,736
  • 4
  • 33
  • 69
2
votes
0 answers

UILabel truncate tail not working with long word and multiple lines

I have several UILabels in tableCells or collectionViewItems set dynamically. Some texts are like this : Sometimesfirstwordverylong and some other words The output is a text not autoshrinked like this : Line 1 : Sometimesfirstwordverylo Line 2 :…
Matthieu
  • 101
  • 1
  • 5
2
votes
2 answers

How to align Right-Justify UILabel?

Remark: Implementing: myLabel.textAlignment = .right does not solves my problem, that is not what I am asking for. What I am trying to achieve is to let the alignment for the label to be Right-Justify. To make it more clear: That's how left…
Ahmad F
  • 30,560
  • 17
  • 97
  • 143
2
votes
1 answer

Resize font size of UILabel based on Frame in Xamarin.iOS

I want to resize the text size of UILabel dynamically. Frame of the UILabel will be changed dynamically. Whenever am changing the UILabel's Frame, font size should be fit with frame. I have tried below code but there is no…
VenkyDhana
  • 905
  • 5
  • 16
2
votes
1 answer

Why can't I call setTitle on UIButton with multiple UIControlStates?

I just spent a few hours finding out that button.setTitle(buttonTitle, for: [.normal, .selected]) is not the same as: button.setTitle(buttonTitle, for: .normal) button.setTitle(buttonTitle, for: .selected) When using more then one UIControlState…
Sethmr
  • 3,046
  • 1
  • 24
  • 42
1 2 3
99
100