Square shadow shadows don't work for me in UITextView

I managed to add shadows to many of the user interface objects in my view, including pretty nicely dropping the shading of some user drawing in the UIImageView. However, the same code does not give anything when applied to a UITextView:

[desc.layer setShadowColor:[[UIColor blackColor] CGColor]]; [desc.layer setShadowRadius:2.0f]; [desc.layer setShadowOffset:CGSizeMake(1, 1)]; [desc.layer setShadowOpacity:0.8f]; 

Is this something I'm missing? I was hoping to use quartz to add border and shadow. The border code works when commenting:

 //Border. /* [desc.layer setBackgroundColor:[[KookaSettings sharedInstance].cellBackgroundColorD CGColor]]; [desc.layer setBorderColor: [[UIColor blackColor] CGColor]]; [desc.layer setBorderWidth:1.0f]; [desc.layer setCornerRadius:8.0f]; */ 
+4
source share
3 answers

I know that the shadow does not work if clipsToBounds is set in the clipsToBounds . Perhaps UITextView has this default value?

+10
source

You need to set clipToBounds to NO for the shadow, but the disadvantage is that if your text is longer than the viewable area of ​​the view, and you need to scroll it, it will no longer be attached to the visible borders of the view, I am looking for a clean way around this.

+1
source

Guillaume is right about clipToBounds settings.

It's a bit dirty, but you can always add a clear view behind a UITextView and cast a shadow on it ...

+1
source

All Articles