1

Say I had a multi-line (can be any number of lines) UIButton positioned in any space in a UIViewController, where the width of the UIButton is constrained by the width of of the whole UIViewController's view, its text is centered inside of the UIButton and word wrapping is on, like so: pic

If I want to find the runtime location of the * in the picture in terms of the whole UIViewController's space, how would I do so?

I attempted to use this post but it only works for single line text and so I can't seem to figure how I am supposed to make it work for multi-line (aka I dont know on which line the * is) text, centered and word wrapped.

Community
  • 1
  • 1
Robert
  • 9
  • 5
  • Do you have to use a `UIButton`? Or is using a `UITextView` with a `UITapGesture` (to perform actions) an option? – Rikh Dec 26 '16 at 07:13
  • Yeah I could, but how would that help with finding the position of a character in the text? – Robert Dec 26 '16 at 17:31
  • Since I can't provide an answer, have a look at [this](http://stackoverflow.com/a/11487125/4539192) answer, it ought to give you a rough idea of what I mean. – Rikh Dec 26 '16 at 17:45
  • Ok thanks, I will see if I can get that to work – Robert Dec 26 '16 at 17:49

1 Answers1

0

To do this use a UITextView and use this post. Just follow the answer and it should work fine.

Community
  • 1
  • 1
Robert
  • 9
  • 5