iOS 3D 图形:3DGraph

jopen 9年前

3DGraph 是一个交互式的 Swift 3D 图形,很简洁,容易安装和使用。

//Create `BarElement`    let bar1 = BarElement(width: 200, height:150, length: 200, color: UIColor.orangeColor(), cornerRadius: 2.5)  let bar2 = BarElement(width: 200, height: 150, length: 150, color: UIColor.redColor(), cornerRadius: 2.5)  let bar3 = BarElement(width: 200, height: 150, length: 180, color: UIColor.blueColor(), cornerRadius: 2.5)    // Optionally you can add labels to the bar element, it needs to be ann array of AttributedString  var label1 = NSMutableAttributedString(string: "Count 76")  label1.addAttributes([NSFontAttributeName: UIFont.systemFontOfSize(4), NSForegroundColorAttributeName: UIColor.whiteColor()], range: NSMakeRange(0, 5))  label1.addAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(4.5)], range: NSMakeRange(5, label1.length-5))    var label2 = NSMutableAttributedString(string: "Value 663.4k")  label2.addAttributes([NSFontAttributeName: UIFont.systemFontOfSize(4), NSForegroundColorAttributeName: UIColor.whiteColor()], range: NSMakeRange(0, 5))  label2.addAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(4.5)], range: NSMakeRange(5, label2.length-5))    var label3 = NSMutableAttributedString(string: "Avg demand 178.9k")  label3.addAttributes([NSFontAttributeName: UIFont.systemFontOfSize(4), NSForegroundColorAttributeName: UIColor.whiteColor()], range: NSMakeRange(0, 10))  label3.addAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(4.5)], range: NSMakeRange(10, label3.length-10))    var label4 = NSMutableAttributedString(string: "Fill(90.04%) 91.96%")  label4.addAttributes([NSFontAttributeName: UIFont.systemFontOfSize(4), NSForegroundColorAttributeName: UIColor.whiteColor()], range: NSMakeRange(0, 12))  label4.addAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(4.5)], range: NSMakeRange(12, label4.length-12))    bar1.labels = [label1, label2, label3, label4]  bar2.labels = [label1, label2, label3, label4]  bar3.labels = [label1, label2, label3, label4]

Preview Image

3DGraph3DGraph3DGraph3DGraph3DGraph3DGraph

项目主页:http://www.open-open.com/lib/view/home/1441786968914