【问题标题】:MKPinAnnotationView left button with an Image带有图像的 MKPinAnnotationView 左按钮
【发布时间】:2013-06-01 12:37:04
【问题描述】:

这是我的代码:

        UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        UIButton* leftButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

        [rightButton setTitle:[(myLocation*)annotation url] forState:UIControlStateApplication];
        [rightButton addTarget:self
                        action:@selector(showDetails:)
              forControlEvents:UIControlEventTouchUpInside];
        customPinView.rightCalloutAccessoryView = rightButton;

        [leftButton setTitle:annotation.title forState:UIControlStateNormal]; 
        customPinView.leftCalloutAccessoryView = leftButton;

它可以工作,但左侧按钮看起来像一个 wite 圆圈中的 i。 我希望绿色的汽车表明可以获取路线。 我该怎么做?

提前致谢

【问题讨论】:

    标签: ios uibutton mkannotationview


    【解决方案1】:

    在这种情况下,您应该创建自定义按钮。

    UIButton * leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton setTitle:annotation.title forState:UIControlStateNormal];
    [leftButton setBackgroundImage:[UIImage imageNamed:@"CAR_IMAGE.PNG"] forState:UIControlStateNormal];
    customPinView.leftCalloutAccessoryView = leftButton;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-05
      • 1970-01-01
      • 2014-09-20
      • 2016-09-01
      • 2011-02-11
      • 2017-09-21
      • 1970-01-01
      • 2013-08-02
      相关资源
      最近更新 更多