Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make multiline UILabel wrap a button

I am using storyboard to design my UIView. But I've stuck at the task: I have a multiline UILabel, UIView and UIButton. I want to make UILabel to wrap my button - the fist line of the text has a trailing constraint to UIButton another one to it's super view. And if my UILabel has no text I got a view at the bottom of label and I need to make this view trailing constraint to UIButton but if I got a free space - to it's superview. Screenshot example:

enter image description here

I want to jump second line word after 'pyat' . Sorry for my poor english, hope that picture could help to explain my question. Is it possible to make it directly in IB?

like image 354
Artem Z. Avatar asked Nov 09 '22 08:11

Artem Z.


1 Answers

Perhaps instead of using UILabel you can try UITextView by using its textView.textContainer.exclusionPaths property to define a button container area to exclude.

Have a look at the sample code with a reported issue for selected and editable case.

As I remember you must limit the app deployment target minimum to 7 or later if using this property.

Hope that helps!

like image 120
NeverHopeless Avatar answered Nov 15 '22 12:11

NeverHopeless