我有很多关于legend的条目.任何人都可以帮助使CPTLegend可滚动吗?
这是我用于CPTLegend的代码.
-(void)configureLegend { // 1 - Get graph instance CPTGraph *graph = self.hostView.hostedGraph; // 2 - Create legend CPTLegend *theLegend = [CPTLegend legendWithGraph:graph]; // 3 - Configure legen theLegend.numberOfColumns = 1; theLegend.fill = [CPTFill fillWithColor:[CPTColor clearColor]]; theLegend.borderLinestyle = [CPTLinestyle linestyle]; theLegend.cornerRadius = 2.0; // 4 - Add legend to graph graph.legend = theLegend; graph.legendAnchor = CPTRectAnchorBottom; CGFloat legendPadding = -(self.view.bounds.size.width / 3); graph.legenddisplacement = CGPointMake(-80,120.0); }
解决方法
您可以创建scrollView并添加图例.这是解决方法,但工作.示例代码:
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,1000,450)]; scrollView.showsverticalScrollIndicator = YES; scrollView.clipsToBounds = YES; scrollView.userInteractionEnabled = YES; scrollView.contentSize = CGSizeMake(scrollView.contentSize.width,5000); [scrollView.layer addSublayer:self.hostView.hostedGraph.legend]; [self.hostView addSubview:scrollView];
附:您应该计算图例和scrollview的坐标以及scrollview的contentSize
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。