我在UITextView上调用了drawRect方法。一切都很好,除了滚动部分。我可以在调用drawRect之前滚动,但现在我不能。我该如何解决这个问题?
这是drawRect方法的代码
import UIKit
@IBDesignable class TextView: UITextView {
override func drawRect(rect: CGRect) {
// Drawing code
//// Bezier Drawing
var bezierPath = UIBezierPath()
bezierPath.moveToPoint(CGPointMake(320, 0))
bezierPath.addCurveToPoint(CGPointMake(320, 433.97), controlPoint1: CGPointMake(320, 0), controlPoint2: CGPointMake(320, 362.81))
bezierPath.addCurveToPoint(CGPointMake(226, 446), controlPoint1: CGPointMake(290.15, 441.8), controlPoint2: CGPointMake(258.61, 446))
bezierPath.addCurveToPoint(CGPointMake(-0, 367.42), controlPoint1: CGPointMake(139.24, 446), controlPoint2: CGPointMake(60.07, 416.3))
bezierPath.addCurveToPoint(CGPointMake(0, 0), controlPoint1: CGPointMake(0, 239.41), controlPoint2: CGPointMake(0, 0))
bezierPath.addLineToPoint(CGPointMake(320, 0))
bezierPath.addLineToPoint(CGPointMake(320, 0))
bezierPath.closePath()
UIColor.grayColor().setFill()
bezierPath.fill()
}
}
这是textView的声明 -
var textView = TextView()
textView.frame = CGRect(x: 0, y: 64, width: 320, height: 504)
textView.text = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda."
textView.textColor = UIColor.blackColor()
textView.textAlignment = .Right
textView.font = UIFont(name: "HelveticaNeue-UltraLight", size: 20)
textView.backgroundColor = UIColor.clearColor()
textView.layer.masksToBounds = false
textView.scrollEnabled = true
textView.editable = false
textView.selectable = false
textView.bounces = false
textView.showsVerticalScrollIndicator = false
self.view.addSubview(textView)