3 回答

TA貢獻2039條經驗 獲得超8個贊
有一個更簡單的解決方案。
創建一個自定義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 關注
- 1037 瀏覽
添加回答
舉報