0

Hi everyone I am creating a text editor and I would like to know if there is the possibility to insert a Uibutton in the middle of the text. I am not referring to a url but to a real button.

For now I am creating the editor with a UIViewRepresentable and then with a regex I look for the part of the text to be transformed

Lorem ipsum dolor sit amet, <button id = "4"> consectetur adipiscing elit. Maecenas ornare </button> eget sapien vel gravida.

My goal is to transform the text between the <button> tag into a UIButton or in any case into a tappable text that can perform an action. To understand the equivalent of

Button (action: {
    self.mode = "normal"
}) {
    Text ("title")
}

some idea? Is it possible to achieve this? Thank you!

Stefano Vet
  • 567
  • 1
  • 7
  • 18
  • Do you have any picture of what you wanted to design? – Steven-Carrot Jul 24 '22 at 21:07
  • You would likely get mixed results because of the `Button` tap gesture would get mixed with the `UIViewRepresentable/UIButton` gesture – lorem ipsum Jul 24 '22 at 21:37
  • simply having a part of a tappable text, but not with a url but performing an action like a normal UIButton – Stefano Vet Jul 25 '22 at 05:02
  • You can do this only at UIKit side, look at NSTextAttachment. – Asperi Jul 25 '22 at 05:23
  • @Asperi NSTextAttachment seems to only work with images. I would need to have some of the text tappable with actions equal to a button. I was thinking of trying to see if it is possible to set an attribute such as TapGesture action to a part of text in a given Range: – Stefano Vet Jul 25 '22 at 06:37

0 Answers0