我想知道是否可以將我的位置按鈕圖像從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. 帶圖像的自定義android按鈕
- 5. 帶圖像的自定義按鈕
- 6. jQuery Mobile自定義圖像按鈕
- 7. 自定義按鈕圖像不適用
- 8. 自定義按鈕與多個圖像
- 9. 後退按鈕自定義圖像
- 10. 圖像自定義後退按鈕
- 11. Android自定義圖像開/關按鈕
- 12. 自定義tumblr像按鈕
- 13. 自定義Facebook像按鈕
- 14. 更改自定義按鈕的狀態(帶圖像的按鈕)?
- 15. 如何在圖像視圖上放置自定義按鈕>
- 16. 自定義按鈕initWithImage在自定義圖像後面顯示默認按鈕
- 17. Mapbox自定義用戶位置圖像
- 18. 谷歌Android的地圖我的位置自定義按鈕(錯誤)
- 19. 使用自定義按鈕控制Google地圖位置
- 20. 我可以設置一個jQueryUI按鈕的自定義圖標
- 21. 如何在我的自定義視圖中放置按鈕?
- 22. Richfaces listshuttle自定義按鈕定位
- 23. 圖像下方的位置按鈕
- 24. 使用css的圖像按鈕位置
- 25. 圖像按鈕裏面的div位置
- 26. 如何創建像圖像一樣的自定義按鈕
- 27. 系統圖標和圖像的自定義導航欄按鈕
- 28. 核心圖形與自定義按鈕的圖像
- 29. 不能爲自定義按鈕設定設定圖像
- 30. 按鈕在對話框中的自定義位置 - jquery ui