3 回答
TA贡献2039条经验 获得超7个赞
有一个更简单的解决方案。
创建一个自定义UIView(用于您的标注)。
然后创建的子类MKAnnotationView,并重写setSelected如下:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
if(selected)
{
//Add your custom view to self...
}
else
{
//Remove your custom view...
}
}
景气,工作完成了。
TA贡献1884条经验 获得超4个赞
继续@TappCandy出色的简单答案,如果您想以与默认气泡相同的方式为气泡设置动画,则我制作了以下动画方法:
- (void)animateIn
{
float myBubbleWidth = 247;
float myBubbleHeight = 59;
calloutView.frame = CGRectMake(-myBubbleWidth*0.005+8, -myBubbleHeight*0.01-2, myBubbleWidth*0.01, myBubbleHeight*0.01);
[self addSubview:calloutView];
[UIView animateWithDuration:0.12 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^(void) {
calloutView.frame = CGRectMake(-myBubbleWidth*0.55+8, -myBubbleHeight*1.1-2, myBubbleWidth*1.1, myBubbleHeight*1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^(void) {
calloutView.frame = CGRectMake(-myBubbleWidth*0.475+8, -myBubbleHeight*0.95-2, myBubbleWidth*0.95, myBubbleHeight*0.95);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.075 animations:^(void) {
calloutView.frame = CGRectMake(-round(myBubbleWidth/2-8), -myBubbleHeight-2, myBubbleWidth, myBubbleHeight);
}];
}];
}];
}
它看起来相当复杂,但是只要您将标注气泡的点设计为居中,您就应该可以替换myBubbleWidth并myBubbleHeight以自己的大小工作。并记住确保子视图的autoResizeMask属性设置为63(即“全部”),以便它们在动画中正确缩放。
:-乔
- 3 回答
- 0 关注
- 989 浏览
添加回答
举报