gpt4 book ai didi

ios - GMSMapView 自定义我的位置按钮图片

转载 作者:可可西里 更新时间:2023-11-01 05:40:53 25 4
gpt4 key购买 nike

我想知道是否可以将我的位置按钮图像从 GMSMapView 更改为自定义图像。

最佳答案

1) 知道框架位置按钮:

   for (UIView *object in self.mapView.subviews) {
if([[[object class] description] isEqualToString:@"GMSUISettingsView"] )
{
for(UIView *view in object.subviews) {
if([view.accessibilityIdentifier isEqual:@"my_location"] ) {

frame = view.frame;

}
}

}
}

使用调试查看正确的帧!!!

2) 不要使用 self.mapView.settings.myLocationButton = YES;

3) 为这个框架创建自己的按钮:

    UIButton *buttonLocation = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonLocation.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 66, [UIScreen mainScreen].bounds.size.height - frame.size.height, frame.size.width, frame.size.height);
[buttonLocation addTarget:self
action:@selector(bLocations:)
forControlEvents:UIControlEventTouchUpInside];
[buttonLocation setImage:[[UIImage imageNamed:@"image.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];

[self.mapView addSubview:buttonLocation];

关于ios - GMSMapView 自定义我的位置按钮图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26757493/

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