【发布时间】:2015-01-30 13:15:16
【问题描述】:
我将自定义 UIButton 添加到 MKAnnotationView(地图上的“图钉”,而不是“气泡”),但是当我这样做时,只有按钮的中心是可点击的。
这是我的按钮的方法:
- (UIButton *)button: (NSString*)text{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(0, 0, 100, 100)];
[[button titleLabel] setLineBreakMode:NSLineBreakByWordWrapping];
text=[NSString stringWithFormat:@"%@",text];
[button setTitle:text forState:UIControlStateNormal];
}
这里我将它添加到 MKAnnotationView 中:
buildingBtn = [self button:annotations.title];
[self addSubview:buildingBtn];
buildingBtn.layer.anchorPoint = CGPointMake(1, 1);
【问题讨论】:
标签: ios uibutton mkannotationview