我想知道是否可以將我的位置按鈕圖像從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. 如何在我的自定義視圖中放置按鈕?