Hãy lấy các điểm đường cong p1, p2, p3, p4 và p5, & tìm điểm giữa cho mỗi cặp điểm lân cận. Nhãn m1 là điểm giữa cho p1 và p2. Tương tự cho m2, m3, m4.
- Thêm đường cong quad để trỏ m2 bằng p2 làm điểm kiểm soát.
- Thêm đường cong quad đến điểm m3 với p3 làm điểm kiểm soát.
- Thêm đường cong bốn để trỏ m4 bằng p4 làm điểm kiểm soát.
Code:
CGFloat screenHeight = self.view.frame.size.height;
CGFloat screenWidth = self.view.frame.size.width;
UIView *aniView = [[UIView alloc] initWithFrame:CGRectMake(50, screenHeight, 50, 50)];
[aniView setBackgroundColor:[UIColor redColor]];
aniView.layer.cornerRadius = 25.0;
[self.view addSubview:aniView];
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:aniView.center];
[movePath addQuadCurveToPoint:CGPointMake(screenWidth-50,screenHeight-50)
controlPoint:CGPointMake(screenWidth/2,screenHeight-150)];
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnim.path = movePath.CGPath;
moveAnim.removedOnCompletion = YES;
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
animGroup.animations = [NSArray arrayWithObjects:moveAnim, nil];
animGroup.duration = 2.0;
[CATransaction begin]; {
[CATransaction setCompletionBlock:^{
[aniView.layer removeAllAnimations];
[aniView removeFromSuperview];
}];
[aniView.layer addAnimation:animGroup forKey:nil];
} [CATransaction commit];
Sao chép qua trên mã vào một số phương pháp và thử gọi phương pháp này ...
Nguồn
2017-08-30 09:19:34
Lưu ý rằng liên kết chỉ câu trả lời không được khuyến khích ở đây trên SO. Vui lòng xem xét [chỉnh sửa câu trả lời của bạn] (http://meta.stackexchange.com/a/8259/186599) và thêm bản tóm tắt tại đây. – NAZIK
@NAZIK danh dự của bạn tôi ở đây để trả lời câu hỏi và tìm một giải pháp thích hợp để querry! – Steve
Tôi đã trải qua hướng dẫn, lấy bài viết của tôi – NAZIK