我想知道是否可以将我的位置按钮图像从GMSMapView更改为自定义图像。GMSMapView自定义我的位置按钮图像
1
A
回答
0
为了做到这一点,您可以从GMSMapView中检索到该按钮的UIButton引用。之后,您只需使用标准的[UIButton setImage:]处理所有不同的状态。我创建了一个类从GMSMapView中控制得到这个的UIButton:
2
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];
相关问题
- 1. 图像不设置自定义按钮
- 2. 自定义图像按钮
- 3. 自定义按钮定位
- 4. UIButtonTypeInfoLight按钮的自定义图像
- 5. 带图像的自定义按钮
- 6. 带图像的自定义android按钮
- 7. 自定义按钮与多个图像
- 8. Android自定义图像开/关按钮
- 9. 黑莓自定义图像按钮
- 10. 单选按钮与自定义图像
- 11. 后退按钮自定义图像
- 12. Facebook共享按钮 - 自定义图像
- 13. 自定义按钮图像不适用
- 14. 图像自定义后退按钮
- 15. MKAnnotationView自定义按钮图像
- 16. iOS UI自定义按钮图像
- 17. jQuery Mobile自定义图像按钮
- 18. 在右下角添加自定义位置按钮,就像GoogleMaps
- 19. 自定义tumblr像按钮
- 20. 自定义Facebook像按钮
- 21. 更改自定义按钮的状态(带图像的按钮)?
- 22. 如何在图像视图上放置自定义按钮>
- 23. 自定义按钮initWithImage在自定义图像后面显示默认按钮
- 24. Mapbox自定义用户位置图像
- 25. 谷歌Android的地图我的位置自定义按钮(错误)
- 26. 设置自定义按钮,选择位图项目从SVG
- 27. 使用自定义按钮控制Google地图位置
- 28. 通过更改大小和位置自定义UINavigationBar按钮和图像
- 29. 自定义视图按钮
- 30. 如何在我的自定义视图中放置按钮?