Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Link π
#5023
Goals β½
Make
MarkerView
work in MacOS, and add an example of it into the MacOS sample app.Implementation Details π§
MarkerView
didSet
inchartView
property, which calls a new functiondidAddToChart(_:)
.didAddToChart(_:)
only does anything in OSX. It adds theMarkerView
as an off-screen subview of thechartView
's containing view. This is necessary because theMarkerView
would not render in OSX without it having been added to a view already. See this SO answer for more context.viewFromXib(in:)
to returnSelf
rather thanMarkerView
so that subclasses will return as their own type rather than the base class.viewFromXib(in:)
to find the first instance ofSelf
in the loaded objects from the xib rather than assuming that the first object in that array was the one we'd be looking for. In MacOS this was a problem because the view was often second in the xib's loaded objects rather than the first.viewFromXib(in:)
, setwantsLayer
to true for the resulting view, which was also necessary to render the view duringdraw(context:point:)
as referenced in previous StackOverflow answer.Testing Details π
RadarMarkerViewMac
in the MacOS sample app, which is nearly identical to theRadarMarkerView
in the iOS sample app.RadarMarkerViewMac
as the marker in the MacOS sample'sRadarDemoViewController
.RadarDemoViewController
displayed the marker as expected.