3 回答

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
有一個(gè)更簡(jiǎn)單的解決方案。
創(chuàng)建一個(gè)自定義UIView(用于您的標(biāo)注)。
然后創(chuàng)建的子類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貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊
繼續(xù)@TappCandy出色的簡(jiǎn)單答案,如果您想以與默認(rèn)氣泡相同的方式為氣泡設(shè)置動(dòng)畫,則我制作了以下動(dòng)畫方法:
- (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);
}];
}];
}];
}
它看起來相當(dāng)復(fù)雜,但是只要您將標(biāo)注氣泡的點(diǎn)設(shè)計(jì)為居中,您就應(yīng)該可以替換myBubbleWidth并myBubbleHeight以自己的大小工作。并記住確保子視圖的autoResizeMask屬性設(shè)置為63(即“全部”),以便它們?cè)趧?dòng)畫中正確縮放。
:-喬
- 3 回答
- 0 關(guān)注
- 1042 瀏覽
添加回答
舉報(bào)