0
我想將BCMeshTransformView庫用於我的swift項目。我創建了一個空的swift項目,並通過可可豆莢添加了該庫。使用BCMeshTransformView時沒有任何顯示
這裏是我的ViewController類:
import UIKit
import BCMeshTransformView
class ViewController: UIViewController {
var transformView:BCMeshTransformView!
var imageView:UIImageView!
var transform:BCMutableMeshTransform!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
transformView = BCMeshTransformView(frame: self.view.bounds)
transformView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
imageView = UIImageView(image: UIImage(named: "picture.jpg")!)
imageView.center = CGPoint(x: transformView.contentView.bounds.midX, y: transformView.contentView.bounds.midY)
transformView.contentView.addSubview(imageView)
transformView.diffuseLightFactor = 0.0
transform = BCMutableMeshTransform.identityMeshTransform(withNumberOfRows: 20, numberOfColumns: 20)
transform.mapVertices { (vertex, vertexIndex) -> BCMeshVertex in
return BCMeshVertex(from: vertex.from, to: vertex.to)
}
transformView.meshTransform = transform
self.view.addSubview(transformView)
}
}
當我運行的應用程序沒有被顯示。它完全是白色的。
刪除此代碼:
transform = BCMutableMeshTransform.identityMeshTransform(withNumberOfRows: 20, numberOfColumns: 20)
transform.mapVertices { (vertex, vertexIndex) -> BCMeshVertex in
return BCMeshVertex(from: vertex.from, to: vertex.to)
}
transformView.meshTransform = transform
不會改變任何東西。
但是,當在Xcode我切換到 「查看UI層次」 我可以看到一個圖像:
這裏是一個全樣本項目:
http://www116.zippyshare.com/v/IUTXbKJg/file.html
爲什麼我什麼都看不見?我試着儘可能簡單地做一個例子。