给地图自定义的大头针添加下降下落动画

给地图自定义的大头针添加下降下落动画

- (无效)MapView类:(的MKMapView *)MapView类didAddAnnotationViews:(NSArray的 *)的意见

{

    (MKAnnotationView * annotationView  的意见)

    {

        (注释isKindOfClass annotationView。:[ CustomAnnotation的类 ])

        {

            [ CATransaction 开始 ;

            / / 设置动画时间

            [ CATransaction 的setValue :[的NSNumber numberWithFloat :0.8F ]  forKey : kCATransactionAnimationDuration ];

            CAKeyframeAnimation * positionAnimation [ CAKeyframeAnimation animationWithKeyPath:“位置” ];

            CGMutablePathRef positionPath =  CGPathCreateMutable();

            CGPathMoveToPoint(positionPath,  NULL,[annotationView  层。位置。所述,annotationView  层。位置。Ÿ - 200);

            positionPath,NULL,annotationView。层位置。CGPathAddLineToPoint(  x,annotationView。层位置。Ÿ);

            CGPathAddLineToPoint(NULL,positionPath,  annotationView。层。位置。x - 1,annotationView。层位置。Ŷ - 1);

            CGPathAddLineToPoint(positionPath,  NULL,annotationView。层位置。所述 + 1,annotationView。层。位置。Ÿ + 1);

            CGPathAddLineToPoint(positionPath,  NULL,annotationView。层。位置x - 1,annotationView。层位置。Ÿ + 1);

            CGPathAddLineToPoint(positionPath,  NULL,annotationView。层位置。+ 1,annotationView。层。位置。Ÿ - 1);

            positionPath,NULL,annotationView。层位置。CGPathAddLineToPoint(  x,annotationView。层位置。Ÿ);

            positionAnimation。路径 positionPath;

            positionAnimation。 timingFunction [ CAMediaTimingFunction functionWithName : kCAMediaTimingFunctionEaseInEaseOut ];

            [annotationView  层addAnimation:positionAnimation  forKey:@“positionAnimation” ];

            [ CATransaction 提交 ;


        }

    }

}

一开始对地图就不了解然后动画只对UIView的动画还算有印象所以当我给地图添加暂未添加了一个自定义的大头针之后我发现只有MKPinAnnotationView这个类有animatedDrop这个下降动画所以怎么给自定义的大头针添加暂未添加下降动画呢最后我用了这个比较笨的方法我先将这个大头针的层移动到实际位置上面200的距离然后让他加个动画让他回到原位置这样就实现了动画下落的效果效果基本和原版相同只不过这大头针的影子是没有动画效果而且我给大头针增加了一个落地之后的颤动效果 


文章转载自  http://hi.baidu.com/dmbxxzmivdbcmxr/item/ba918c871113e550e63d1900

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值