【问题标题】:core plot Framework - How to set custom UIView in CPTPlotSpaceAnnotation核心情节框架 - 如何在 CPTPlotSpaceAnnotation 中设置自定义 UIView
【发布时间】:2013-04-30 14:25:28
【问题描述】:

如果按下绘图符号,我想使用scatterPlot:plotSymbolWasSelectedAtRecordIndex: 方法在我的图表中设置一个带有标签出口的自定义uiview。

但是如何给绘图区域提供 UIView 或者如何覆盖 CPTLayer 来绘制我的自定义 UIView?

谢谢

【问题讨论】:

    标签: uiview plot core-plot


    【解决方案1】:

    CPTLayerCALayer 的子类,因此您不能只使用自定义UIView 作为Core Plot 注释。但是,您可以将自定义视图作为 Core Plot 托管视图的同级插入(不是子视图!)。使用绘图空间获取绘图区域中被触摸数据点的坐标,并使用内置的CALayer方法将坐标从绘图区域层转换为图形层。

    【讨论】:

    • 好的,我得到了正确的坐标,但是如何将我的视图作为托管视图的兄弟插入?我试图将我的 View 添加到 hostingView 但没有任何反应。
    • 我试过这样的:CGPoint viewPoint = [plot plotAreaPointOfVisiblePointAtIndex:index];MyCustomView *view = [MyCustomView alloc] initWithFrame:CGRectMake(viewPoint.x,viewPoint.y,100,100);[self.graph.hostingView addSubview:view];
    • 将您的视图添加到托管视图的 父级
    猜你喜欢
    • 2020-09-29
    • 1970-01-01
    • 2012-06-25
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    相关资源
    最近更新 更多