hch*_*n02 6 iphone objective-c ipad ios
我想用阴影UITextView来看看UITextField.任何想法?我在用
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;
Run Code Online (Sandbox Code Playgroud)
但UITextView如果UITextView背景是透明的,它会给文本留下阴影.所以有任何想法如何给UITextView像这样的层 - 阴影

// 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;
Run Code Online (Sandbox Code Playgroud)
该类没有指定这样的属性。您必须自己创建它。为了使用代码创建它,您必须使用QuartzCore框架。首先将其导入到文件中,然后可以设置以下属性:
#import <QuartzCore/QuartzCore.h>
textView.layer.cornerRadius = 30;
textView.clipsToBounds = YES;
textView.backgroundColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)
此代码假设您已设置名称为textView 的文本视图。只需更改cornerRadius 即可满足您的需要。这使得 textView 显示像您显示的图片一样。
| 归档时间: |
|
| 查看次数: |
7911 次 |
| 最近记录: |