2
votes

I can't find the right answer. I have got an image as a subview in my table view's refresh controll. I want to rotate it while I am pulling to refresh. The rotation angle should be dependent on refresh's controll height. I was trying to use CGAffineTransformMakeRotation and CGAffineTransformRotate bu it wasn't working at all. Do any one know a solution for that?

1
Define "wasn't working at all". Do you get errors, does it not rotate, does it rotate differently than you expect? What does your code look like currentlyChris Slowik
I am trying to rotate and change frame at the same time and it deforms the image. CGFloat pullDistance = MAX(0.0, -self.refreshControl.frame.origin.y); CGFloat spinnerY = pullDistance / 2.0 - spinnerHeightHalf; CGFloat spinnerX = self.view.center.x; CGRect spinnerFrame = self.compass_spinner.frame; spinnerFrame.origin.x = spinnerX; spinnerFrame.origin.y = spinnerY; CGFloat angle = (pullDistance)/M_PI*180; self.compass_spinner.transform = CGAffineTransformMakeRotation(angle);Bart

1 Answers

0
votes

UIScrollView, vertical scrolling and Swift 5:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    let topOffset = scrollView.contentOffset.y
    let angle = -topOffset * 2 * CGFloat(Double.pi / 180)
    self.myImageView.transform = CGAffineTransform(rotationAngle: angle)
}

Don't forget to do this in viewDidLoad:

self.scrollView.delegate = self