-2

I am new to swift and trying to create a to-do list app. The following code block is what I am working with:

//MARK: - horizontal pan gesture methods
func handlePan(recognizer: UIPanGestureRecognizer) {
  // 1
  if recognizer.state == .Began {
    // when the gesture begins, record the current center location
    originalCenter = center
  }
  // 2
  if recognizer.state == .Changed {
    let translation = recognizer.translationInView(self)
    center = CGPointMake(originalCenter.x + translation.x, originalCenter.y)
    // has the user dragged the item far enough to initiate a delete/complete?
    deleteOnDragRelease = frame.origin.x < -frame.size.width / 2.0
  }
  // 3
  if recognizer.state == .Ended {
    // the frame this cell had before user dragged it
    let originalFrame = CGRect(x: 0, y: frame.origin.y,
        width: bounds.size.width, height: bounds.size.height)
    if !deleteOnDragRelease {
      // if the item is not being deleted, snap back to the original location
      UIView.animateWithDuration(0.2, animations: {self.frame = originalFrame})
    }
  }
}

The error message: 'CGPointMake' is unavailable in Swift

Searched google and nothing specifically relating to this problem on Google to how to update this operation.

Is there a new way to preform this same function?

Please help. Thank you

Rocky1289
  • 1
  • 1

2 Answers2

0

You use the CGPoint constructor

center = CGPoint(x: originalCenter.x + translation.x, y: originalCenter.y)
idz
  • 12,825
  • 1
  • 29
  • 40
0

CGPoint(x: xPos, y:yPos).

Change your

CGPointMake(startX, startY) to CGPoint(x: startX, y: startY)

and you can create a CGPoint

Sumit_VE
  • 429
  • 2
  • 12