gpt4 book ai didi

ios - 只有 UIButton 的中心是可点击的

转载 作者:行者123 更新时间:2023-11-29 12:29:09 25 4
gpt4 key购买 nike

我正在将自定义 UIButton 添加到 MKAnnotationView( map 上的“图钉”,而不是“气泡”),但是当我这样做时,只有按钮的中心是可点击的。

这是我的按钮的方法:

- (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);

最佳答案

UIButton 的框架可能比 MKAnnotationView 的框架大。如果是这种情况,该按钮将不会接收任何位于注释 View 边界之外的位置的触摸。

关于ios - 只有 UIButton 的中心是可点击的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28236760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com