views:

276

answers:

1

Hi folks, finally I choose to devote some time to find a way/implementation to mask text inside UITextView/UIWebView. By now what I'm able to do is: - add some custom background - add a uitextview/uiwebview with some text - add an UIImageView (with a covering png) or a CAGradientLayer to create a simple mask effect (*) Of course this is not a magic bullet and require at least one more layer (the one pointed out with *). Furthermore it's not so good when you have a full transparent background 'cause everyone can recognize the extra view/layer used to fade away the text. I searched all over google but still not found a good solution (I've found about mask an image, blah blah)... Any tips? Thanks in advance, marcio

PS maybe a screenshot will be more straightforward, here you're! http://grab.by/KzS

A: 

Yes! I finally got it. I don't know if it's the Apple's way but it works. Maybe they have the opportunity to employ some private apis. Anyway this is a sort of pseudo-algorithm on how I got it works:

1) get a screenshot of the window

2) crop the desired rect with CGImageCreateWithImageInRect

3) apply a gradient mask (stolen from Apple' sample code on Reflections)

4) create an UIImageView with the freshly created image

I also noted that it doesn't affect the performances even on the lowest devices. Hope it will be helpful! And this is a crop of the result (link text)

marcio