将阴影添加到UITextView的框架中,也将阴影添加到文本中

时间:2012-11-15 10:51:36

标签: ios uitextview dropshadow quartz-core

我有一个UITextView,我在框架中添加了一些阴影,但是当我写的时候,文本也得到了相同的阴影。如何避免这个问题?

我的代码:

commentary = [[UITextView alloc]initWithFrame:CGRectMake(10, 435, 230, 120)];
commentary.font = STANDARDFONT;
commentary.backgroundColor = BACKGROUND;
commentary.layer.shadowColor = [UIColor blackColor].CGColor;
commentary.layer.shadowOffset = CGSizeMake(2, 2);
commentary.layer.shadowOpacity = 0.8;
commentary.layer.shadowRadius = 2.0;
commentary.layer.borderColor = [UIColor grayColor].CGColor;
commentary.layer.borderWidth = 1.5;
commentary.layer.cornerRadius = 5;
commentary.layer.masksToBounds = NO;
commentary.clipsToBounds = NO;
[self addSubview:commentary];

BACKGROUND和STANDARDFONT是[UICOLOR clearColor].CGColor[UIFont fontWithName:@"TimesNewRomanPSMT" size:16];

1 个答案:

答案 0 :(得分:0)

尝试设置图层背景颜色:commentary.layer.backgroundColor = BACKGROUND.CGColor