Skip to content

UIView.image does not capture subviews #276

Description

@skhillon

Summary

When I use the LocationAnnotationNode(location:view:) constructor, the view.image extension does not capture subviews such as labels when converting to UIImage.

For some reason (and I am not entirely sure why), this problem goes away when I call view.addSubview(cardView), but this also adds a new view to the window.

Code

  func addARAsset(poi: AliasablePOI) {
    let coordinate = CLLocationCoordinate2D(latitude: poi.latitude, longitude: poi.longitude)
    let location = CLLocation(coordinate: coordinate, altitude: Constants.AR.altitudeInMeters)
    let cardView = ARCardView(poi: poi)
    //view.addSubview(cardView)  <-- required
    let annotationNode = LocationAnnotationNode(location: location, view: cardView)
    annotationNode.scaleRelativeToDistance = false
    sceneLocationView.addLocationNodeWithConfirmedLocation(locationNode: annotationNode)
  }

Without addSubview

IMG_8410

After addSubview

IMG_8411

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions