0

I would like to style my Google Maps InfoWindows - if i create a custom UIView here:

 func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {

    var infoWindow = UIView(frame: CGRectMake(0,0,280,40))
    infoWindow.backgroundColor = UIColor.lightGrayColor()
    ...

Thats easy - but i would like to have a triangle shape on the bottom, so first i though if creating a View in a View, like here:

enter image description here

View1 would be transparent - View2 is my ContentWindow, View3 is the triangle Shape. So all 3 should be my "own" Popover.

As rounded triangle shape i would like to have the same as a standard UIPopover has. Like that:

enter image description here .

Should i use an Image for View3 - OR is it possible to Subclass a UIPopoverView (for all 3 Views) - So i already got the Triangle Shape? Or can i draw such an Trangle Shape with Core Graphics?

That should be the solution (with rounded triangle shape at the bottom):

enter image description here

derdida
  • 14,784
  • 16
  • 90
  • 139
  • you should use popOver..... – LC 웃 Aug 05 '15 at 11:23
  • you are saying view3 should be as UIPopover...or on tap you want to show view as popover? – LC 웃 Aug 05 '15 at 11:25
  • No, the whole infowindow should be look like an UIPopover. So including the little rounded triangle on the bottom. My 3 Views is only an idea how (i already know) i could do it - but maybe is subclassing an UIPopover an (better) way. – derdida Aug 05 '15 at 11:27
  • you want your view 2 to be popover and you want view3 to be drawn inside of UIPopover? – LC 웃 Aug 05 '15 at 11:38
  • No, i want to create only a (simple) View, that looks like an UIPopover. So a View with an rounded triangle (centered) on the bottom. My 3 Views is ANOTHER way how i am able to solve that (so i would create my own Popover style with 3 UIViews) - but i want to know if there is a way to subclass an UIPopover (which contains everything i need) - ill edited my question, hopefully its now clear ;) – derdida Aug 05 '15 at 11:41
  • sorry i didnot get you..but you might consider subclassing UIPopoverBackgroundView – LC 웃 Aug 05 '15 at 11:55
  • any update on this? how this can be done in swift 4? – Mak13 Apr 12 '19 at 07:02

1 Answers1

0

You can mask your custom view to be used as infoWindow. Refer to How to mask a UIView on how to mask uiview with image.

Community
  • 1
  • 1
Xchord
  • 678
  • 1
  • 5
  • 20