我想做的就是采用基本的arkit视图并将其转换为黑白视图.现在基本视图是正常的,我不知道如何添加过滤器.理想情况下,在截取屏幕截图时,黑白过滤器会添加到屏幕截图中.
import UIKit
import SceneKit
import ARKit
class ViewController: UIViewController, ARSCNViewDelegate {
@IBOutlet var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
sceneView.delegate = self
sceneView.showsStatistics = true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
sceneView.session.pause()
}
@IBAction func changeTextColour(){
let snapShot = self.augmentedRealityView.snapshot()
UIImageWriteToSavedPhotosAlbum(snapShot, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}
}
Run Code Online (Sandbox Code Playgroud) 下面的代码在UIView上打印一行.我只想知道我要编写的代码,以便能够在视图顶部插入图像.
import UIKit
class draw: UIView {
var line = UIBezierPath()
var line1 = UIBezierPath()
func grapher() {
line1.move(to: .init(x:0, y: bounds.height / 6))
line1.addLine(to: .init(x: bounds.width, y: bounds.height / 6))
UIColor.blue.setStroke()
line1.lineWidth = 2
line1.stroke()
}
override func draw(_ rect: CGRect) {
grapher()
}
}
Run Code Online (Sandbox Code Playgroud)