Xin lỗi vì một câu hỏi lớn, câu hỏi thực tế là đậm ở dưới cùng, bây giờ là một số giải thích.Di chuyển động của UIScrollView bằng CoreAnimation
Tôi đang sử dụng CoreAnimation trong dự án của mình để tạo hoạt ảnh cho một số đối tượng chuyển động như thế này.
CABasicAnimation *moveAnimation;
moveAnimation=[CABasicAnimation animationWithKeyPath:@"position"];
moveAnimation.duration = 2.0;
moveAnimation.repeatCount=1;
moveAnimation.autoreverses=NO;
moveAnimation.delegate = self;
moveAnimation.fromValue = [NSValue valueWithCGPoint:[crawler.layer position]];
moveAnimation.fillMode = kCAFillModeForwards;
moveAnimation.removedOnCompletion = NO;
CGPoint p;
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)];
[crawler.layer addAnimation:moveAnimation forKey:@"moveAnimation"];
Và bây giờ tôi cần tạo hiệu ứng động của một số UIScrollView. Tôi không thể sử dụng phương thức setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
vì không thể tùy chỉnh thời lượng hoạt ảnh.
tôi có thể làm cho nó như thế này
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
scrollView.contentOffset = CGPointMake(scrollView.contentOffset.x + 200, scrollView.contentOffset.y);
[UIView commitAnimations];
nhưng nó không phải CoreAnimation, và sử dụng 2 loại khác nhau của các kỹ thuật hoạt hình trong một ứng dụng không phải là một thực hành tốt, tôi nghĩ.
Có cách nào để sử dụng CoreAnimation để tạo hiệu ứng cuộn nội dung UIScrollView cho điểm tùy chỉnh với thời lượng hoạt ảnh tùy chỉnh không? P.S. Xin lỗi vì tiếng Anh xấu.
Cảm ơn rất nhiều. Đây là những gì tôi cần bây giờ. – Padavan