How to limit the representation of the first baseline of a UITextView?

I am desperately trying to limit the first baselines of UILabel and UITextView in Interface Builder. In my opinion, this should be pretty simple by simply adding the following restriction (Pseudocode):

 label.firstBaseline = textView.firstBaseline 

However, depending on other restrictions and some viewing options, I get really uncomfortable results, as shown in the following screenshots.

1st case: disable scrolling and align top edges

This is just to show the general presentation setting. I have disabled scrolling for textView to avoid ambiguity. (Otherwise, textView cannot calculate its own height from the containing text.)

1st case: align the upper edges of both views

Second case: disable scrolling and align the first baselines

The same settings as in the first case, with the only difference being that I removed the constraint that aligns the top edges of the views and adds a constraint that aligns the first base levels of the views.

For some reason, the label β€œflies” far beyond its supervisor and ends at position y 7764. I don’t know why.

Second case: align the first baselines

3rd case: height and alignment of the first baseline

Now I have a scroll for textView and instead its height is limited.

Obviously, the first label baseline aligns with the top edge of the textView , although low-key says it aligns their first baselines. I read in Apple docs that the firstBaseline parameter returns the top edge of the view if this view does not have a baseline. Thus, it seems that textView does not have a first baseline in this scenario.

3rd case: align the first baselines and add a height limit

Is there a UITextView at all no firstBaseline ? And if so: why? After all, this is the view that draws the text, and so this property must be set.

Any thoughts on this are appreciated.

+5
source share

All Articles