我已经在应用程序中使用引脚图像而不是标准引脚,现在我想给定制引脚赋予动画(如同标准引脚一样放置效果)。我怎样才能提供滴定动画效果自定义引脚图像?自定义引脚动画-MKMapView
9
A
回答
24
实施以下委托方法。
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
MKAnnotationView *aV;
for (aV in views) {
CGRect endFrame = aV.frame;
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - 230.0, aV.frame.size.width, aV.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.45];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[aV setFrame:endFrame];
[UIView commitAnimations];
}
}
+5
这个效果很好。应该标出正确答案。 – 2010-08-26 15:32:46
6
,如果你不删除所有引脚一次下降,但他们每个人有一个小的延迟,使得它看起来像有一种针效果雨也感觉更酷。类似于苹果本身所做的。使用这个:
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
MKAnnotationView *aV;
float delay = 0.00;
for (aV in views) {
CGRect endFrame = aV.frame;
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - 430.0, aV.frame.size.width, aV.frame.size.height);
delay = delay + 0.01;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:delay];
[UIView setAnimationDuration:0.45];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[aV setFrame:endFrame];
[UIView commitAnimations];
}
}
+0
是的,这很酷!谢谢 – PrasadW 2015-01-06 06:57:58
0
这对我很好。不记得在那里我发现它这里虽然
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
MKAnnotationView *aV;
for (aV in views) {
// Don't pin drop if annotation is user location
if ([aV.annotation isKindOfClass:[MKUserLocation class]]) {
continue;
}
// Check if current annotation is inside visible map rect, else go to next one
MKMapPoint point = MKMapPointForCoordinate(aV.annotation.coordinate);
if (!MKMapRectContainsPoint(self.mapView.visibleMapRect, point)) {
continue;
}
CGRect endFrame = aV.frame;
// Move annotation out of view
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - self.view.frame.size.height, aV.frame.size.width, aV.frame.size.height);
// Animate drop
[UIView animateWithDuration:0.3 delay:0.03*[views indexOfObject:aV] options:UIViewAnimationCurveLinear animations:^{
aV.frame = endFrame;
// Animate squash
}completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.05 animations:^{
aV.transform = CGAffineTransformMakeScale(1.0, 0.8);
}completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.5 animations:^{
aV.transform = CGAffineTransformIdentity;
}];
}
}];
}
}];
}
}
0
注意,在-mapView:didAddAnnotationViews:
动画注解视图导致奇怪的效果时MKMapView.userTrackingMode
等于MKUserTrackingModeFollowWithHeading
。我只希望苹果公司能够为MKAnnotationView
课程提供下载动画。
0
夫特3降动画
// animate annotation views drop
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
for annView in views {
// animate any annotation views except the user pin
if !(annView.annotation?.isKind(of: MKUserLocation.self))! {
let endFrame = annView.frame
annView.frame = endFrame.offsetBy(dx: 0, dy: -500)
UIView.animate(withDuration: 0.5, animations: {
annView.frame = endFrame
})
}
}
相关问题
- 1. MKAnnotations自定义引脚放置动画
- 2. 自定义注释引脚干扰iphone上的mkmapview的showuserlocation
- 3. MKMapView显示为自定义引脚的当前位置
- 4. 自定义注释引脚
- 5. 引脚移动后MKMapView刷新
- 6. 自定义动画类
- 7. 动画自定义演示
- 8. 自定义的UINavigationController动画
- 9. 自定义动画在Raphael.js
- 10. 自定义modalViewController动画
- 11. 自定义UIScrollView动画
- 12. 自定义CALayer动画
- 13. 自定义UINavigationController动画:CATransition
- 14. Glide的自定义动画
- 15. viewpager的自定义动画
- 16. 创建自定义动画
- 17. Android自定义ProgressDialog动画
- 18. UITableViewRowAnimation自定义动画
- 19. iPhone UIButton自定义动画
- 20. Android - 自定义ViewPager动画
- 21. 自定义动画navigationItem
- 22. MKMapView - 它缓存引脚吗?
- 23. MKMapView不集中在引脚
- 24. 自定义推动segue动画
- 25. 用自定义动画显示活动
- 26. 动画跨越的MKMapView
- 27. 添加自定义注释到的MKMapView
- 28. iOS MKMapView的自定义注释
- 29. MKMapView的Swift自定义标注
- 30. 自定义Lightswitch自动完成页脚
[这应该有助于](http://stackoverflow.com/questions/1857160/how-can-i-create-a-custom-pin-drop- animation-using-mkannotationview) – dwery 2010-04-17 14:23:46