【问题标题】:Callout accessory view with grey arrow button not blue 'i' button带有灰色箭头按钮而非蓝色“i”按钮的标注附件视图
【发布时间】:2014-07-21 15:58:01
【问题描述】:

我看到很多关于如何将标注附件视图添加到注释的示例:

        UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
        [rightButton addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
        annotationView.rightCalloutAccessoryView = rightButton;

但是,这给了我一个蓝色的信息按钮:

但我真的想要灰色箭头按钮:

有没有办法从 SDK 中获取这种类型的按钮。我尝试了 UIButton 中定义的所有按钮类型,但没有运气。

【问题讨论】:

  • 很遗憾,详细信息披露按钮样式在 iOS7 中不可用(请参阅stackoverflow.com/questions/22012468/…)。相反,请使用带有灰色箭头图像的按钮。此外,将目标和操作设置为 nil 没有意义(实现 calloutAccessoryControlTapped 委托方法而不是自定义操作通常更好)。

标签: ios mkmapview mkannotationview


【解决方案1】:

获取箭头图像并将其设置在标注附件视图中

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[rightButton setImage:[UIImage imageNamed:@"abc.png"] forState:UIControlStateNormal];
[rightButton setImage:[UIImage imageNamed:@"abc.png"] forState:UIControlStateHighlighted];
[rightButton addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;

【讨论】:

    猜你喜欢
    • 2018-11-25
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-01
    • 2021-07-09
    • 2014-11-20
    • 2018-11-09
    相关资源
    最近更新 更多