我在应用程序中使用了pin图像而不是标准引脚,现在我想给自定义引脚提供动画(与标准引脚一样的效果).如何为自定义图钉图像提供下降动画效果????
Bir*_*chi 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];
}
}
Run Code Online (Sandbox Code Playgroud)
如果你不是一次性掉落所有的引脚,而是稍微放下它们,那么它的感觉也会变得很凉爽,这样看起来就像是有针雨的效果.与Apple原生的相似.用这个:
- (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];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5388 次 |
| 最近记录: |