I am trying to setup a view allow you to draw a signature. All my selectors and UIGestureRecognizors seem to be working based on what i'm getting in my logs but nothing is showing on my screen after movement. Does anyone see something i'm missing that is not allowing the stroke to show up with my gesture? Any help would be very appreaciated
class SignatureController < UIViewController
def viewDidLoad
self.title = "Please Sign"
self.view.backgroundColor = UIColor.whiteColor
@path = UIBezierPath.bezierPath
@path.setLineWidth(2.0)
pan = UIPanGestureRecognizer.alloc.initWithTarget(self, action: 'pan:')
pan.maximumNumberOfTouches = pan.minimumNumberOfTouches = 1
self.view.addGestureRecognizer(pan)
super
end
def pan(pan)
currentPoint = pan.translationInView(self.view)
case pan.state
when UIGestureRecognizerStateBegan
@path.moveToPoint(currentPoint)
when UIGestureRecognizerStateChanged
@path.addLineToPoint(currentPoint)
NSLog("#{currentPoint}")
else
p "SwipeGesture unrecognized"
end
self.view.setNeedsDisplay
end
def drawRect(rect)
UIColor.blackColor.setStroke
@path.stroke
end
end
The issue came from using UIViewController vs. UIView. The UIBezierPath only runs under the UIView call. After using this my code worked perfect. Thanks.