I have created a shadow using QuartzCore for my UITextView with this following code.
myTextView.layer.masksToBounds = NO;
myTextView.layer.shadowColor = [UIColor blackColor].CGColor;
myTextView.layer.shadowOpacity = 0.7f;
myTextView.layer.shadowOffset = CGSizeMake(2.0f, 2.0f);
myTextView.layer.shadowRadius = 8.0f;
myTextView.layer.shouldRasterize = YES;
It creates a shadow and looks good too. Here it is my output for the above code.

But When I try to add a text to the myTextView, my textView text goes out of the bounds and it looks outside of the myTextView like below.

It's happening only when I add shadow. The text inside the textView is not showing weird If I don't add shadow.What I am doing wrong?? How could I overcome this? Why it is happening?
UPDATE:
@borrrden said
I found It is happening, because of setting the maskToBounds = NO; If we set YES then we cannot get shadow. Reason Here it is an answer
There is no "right" solution, because of UIView behavior. When masksToBounds is NO, any sublayers that extend outside the layer's boundaries will be visible. And UITextField scroll text outside the UITextField layer.
Add clear view behind the UITextView and drop a shadow on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With