我刚刚使用最新版本的CorePlot更新了我的应用程序(v2.3,我之前运行的版本是
final class GraphView: CPTGraphHostingView,CPTPlotDataSource {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configureGraph()
...
}
fileprivate func configureGraph() {
// Graph theme
graph.apply(CPTTheme(named: .plainWhiteTheme))
// Hosting view
self.hostedGraph = graph
// Plot Space
plotSpace = graph.defaultPlotSpace as! CPTXYPlotSpace
}
我注意到在新版本中可以继承UIView而不是CPTGraphHostingView:
final class GraphView: UIView,CPTPlotDataSource {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configureGraph()
...
}
fileprivate func configureGraph() {
// Graph theme
graph.apply(CPTTheme(named: .plainWhiteTheme))
// Hosting view
let hostingView = CPTGraphHostingView(frame: self.frame)
hostingView.hostedGraph = graph
self.addSubview(hostingView)
// Plot Space
plotSpace = graph.defaultPlotSpace as! CPTXYPlotSpace
}
在大多数情况下都可以,但是我的一个图形位于ScrollView(启用了分页)上,因此在这种情况下为self.frame
获取hostingView
并不容易。
我在这个新版本中缺少什么吗?
谢谢!