i want to apply shadow on UITextView
to give a look like UITextField
.Any Idea?
I am using
textView.layer.shadowOpacity=0.8;
textView.layer.shadowColor=[[UIColor lightGrayColor] CGColor];
textView.layer.shadowOffset=CGSizeMake(0, 0);
textView.layer.shadowRadius=3;
textView.layer.cornerRadius=3;
but it gives shadow to the text of UITextView
if the UITextView
background is transparent.
so is there any idea how to give shadow to layer of UITextView
like this->
// Add shadow
[textView.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
[textView.layer setBorderColor: [[UIColor grayColor] CGColor]];
[textView.layer setBorderWidth: 1.0];
[textView.layer setCornerRadius:12.0f];
[textView.layer setMasksToBounds:NO];
textView.layer.shouldRasterize = YES;
[textView.layer setShadowRadius:2.0f];
textView.layer.shadowColor = [[UIColor blackColor] CGColor];
textView.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
textView.layer.shadowOpacity = 1.0f;
textView.layer.shadowRadius = 1.0f;
The class doesn't specify such a property. You will have to create it yourself. In order to create it with code, you will have to use the QuartzCore framework. First you import it to your file and then you can set the following properties:
#import <QuartzCore/QuartzCore.h>
textView.layer.cornerRadius = 30;
textView.clipsToBounds = YES;
textView.backgroundColor = [UIColor whiteColor];
This code supposes that you have your textview set up with the name: textView. Just change the cornerRadius to fit what you need. This makes the textView show like the picture you showed.
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