UITextView边界之外的文本

时间:2013-02-25 03:45:00

标签: objective-c cocoa-touch uitextview quartz-core

在我的iOS应用中,我正在尝试使用QuartzCore向UITextView添加阴影,但我最终会在UITextView的范围之外滚动文字:

enter image description here

我尝试使用Text scrolls outside of the UITextView box boundary处的解决方案,但没有一个解决方案有效。当我将textView.contentInset = UIEdgeInsetsZero;放入UITextView方法时,第一个解决方案viewDidLoad[textView setClipsToBounds:YES];完全没有任何作用。第二个解决方案摆脱了我想要添加的阴影:textView.layer.masksToBounds = NO; textView.layer.shadowOffset = CGSizeMake(-1, 1); textView.layer.shadowRadius = 3; textView.layer.shadowOpacity = 0.3;

这是我用来创建阴影的Quartz Core代码:

{{1}}

我做错了什么?这是iOS中的错误吗?如果是这样,有没有解决方法或解决方案?

1 个答案:

答案 0 :(得分:0)

您可以使用它来获取内容大小:

textView.frame = CGRectMake(0, 0, textView.contentSize.width, textView.contentSize.height);