1

Is it generally possible with an UITextView to have a mask which I can animate at runtime? Imagine a flash light effect: You have a circle mask and then move this circle around -- and only whatever is in the circle is shown of the UITextView.

Sorry to be so general, but I was only wondering if this is generally possible with an UITextView and where I would need to start to achieve such an effect. I found this: Mask UIView and this Mask text inside UITextView but neither is really about animating a mask at runtime.

Thanks!

Community
  • 1
  • 1
n.evermind
  • 11,944
  • 19
  • 78
  • 122
  • 1
    It is possible. My OSX device is at work at the moment, but if I get a lunch break today, I'll whip up some sample code to do the trick. But really, [this](http://stackoverflow.com/questions/3059622/how-to-mask-a-uiview) will do the trick, you just have to replace the static CGImage with one generated at runtime. You'll need to know the quartz or OpenGL-ES frameworks in any case. – Jordaan Mylonas Mar 28 '11 at 20:16
  • @Jordaan Mylonas: Thanks, very kind of you. If you have some sample code, that would be brilliant. Otherwise, I fight my way through and see what I can come up with. Knowing that it is not difficult will make things easier! Thanks a lot! – n.evermind Mar 28 '11 at 21:03
  • @Jordaan Mylonas: Thanks, I've tried it and it works. I'm now trying to crop an UITextView so as to show another UITextView in the back of it. I explained it in more detail [here](http://stackoverflow.com/questions/5469865/how-to-crop-an-uitextview)... is that easy as well or will this be very problematic? – n.evermind Mar 29 '11 at 10:20

1 Answers1

2

Yes this is completely possible and easy.

It is very likely you *do not need the difficult concept of masks, as explained in the links you mention.

All you have to do is make another UIView (just do it in IB), and then move that new UIView around as you see fit.

It's just that easy. Hope it helps.

Fattie
  • 27,874
  • 70
  • 431
  • 719
  • Thanks, but I don't really understand how another UIView will be a mask of my original UIView and how I can tell it in IB that it should behave like a mask? Sorry if this is obvious, but as you can tell, I'm rather new in all of this. THanks! – n.evermind Mar 28 '11 at 21:05
  • UIView doesn't have to cover the whole screen. You can create UIView with size 20 by 20, set it's alpha to 50 % and paint it red, then add it as subview of current view and move it around. UIView is omnipotent object and can be made to do million things. – TheBlack Mar 28 '11 at 21:20
  • @TheBlack: I've tried this and it works. I'm now trying to crop an UITextView so as to show another UITextView in the back of it. I explained it in more detail [here](http://stackoverflow.com/questions/5469865/how-to-crop-an-uitextview)... is that easy as well or will this be very problematic? – n.evermind Mar 29 '11 at 10:21
  • I've tried this and it works. I'm now trying to crop an UITextView so as to show another UITextView in the back of it. I explained it in more detail [here](http://stackoverflow.com/questions/5469865/how-to-crop-an-uitextview)... is that easy as well or will this be very problematic? – n.evermind Mar 29 '11 at 10:21