1

I am trying to create uitextview' text as a mask for background image so that I can color text dynamically with respect to the image behind. I can make that thing through the design application by converting text into outline paths and use it as a mask to the background image. Here is the link for a sample text

However fail to do that in iOS, as I need to convert textview text into path which is somewhat very problematic for me.

I would be happy if someone at least show me the general way to do that.

Thanks

1 Answers1

1

You can place the uitextview (with a black text) on a white background and take a snapshot of that view, like this: How Do I Take a Screen Shot of a UIView?

Then, you can use the resulting image as a mask on your background image, like this: How to Mask an UIImageView

I hope this helps. Good Luck!

Community
  • 1
  • 1
Rony Rozen
  • 3,957
  • 4
  • 24
  • 46
  • Ok thanks but I need to show text with background as the text is typed in the textview. – memetcircus Aug 24 '15 at 19:40
  • It may be a bit slow but you can use the same logic I suggested (set your class as the uitextfield's delegate and take a screenshot of that section of the screen whenever the text changes). I would recommend against it, since it may make the app much slower to respond. Maybe at least add some sort of timer (only update the display when the user stopped typing for a second of so). – Rony Rozen Aug 24 '15 at 19:54
  • 1
    Now I add an uimageview behind the textview and apply this code in the viewdidload method: backgroundImage.layer.mask = specialTextView.layer After that I get what I want exactly but this time textView is locked and I can not add any text into it. – memetcircus Aug 24 '15 at 20:15