core plot Framework - How to set custom UIView in CPTPlotSpaceAnnotation

谁都会走 提交于 2020-01-04 05:48:23

问题


I want to set a custom uiview with label outlets in my graph, if a plot symbol was pressed, using the scatterPlot:plotSymbolWasSelectedAtRecordIndex: method.

But how can I give the plot area the UIView or how can I override CPTLayer to draw my custom UIView?

Thank you


回答1:


CPTLayer is a subclass of CALayer, so you can't just use the custom UIView as a Core Plot annotation. However, you could insert your custom view as a sibling of the Core Plot hosting view (not a subview!). Use the plot space to get the coordinates of the touched data point in the plot area and use the built-in CALayer methods to convert the coordinates from the plot area layer to the graph layer.



来源:https://stackoverflow.com/questions/16302288/core-plot-framework-how-to-set-custom-uiview-in-cptplotspaceannotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!