【发布时间】:2015-07-08 01:12:16
【问题描述】:
我正在尝试为我的简单绘图应用程序清除绘图画布。我创建了一个按钮,通过将UIImageView.image 设为 nil 来删除图像。但是,按下按钮时没有任何反应。
ViewController 代码:
import UIKit
var smoothLineView : SmoothLineView = SmoothLineView()
class ViewController: UIViewController {
@IBOutlet weak var mainDrawingCanvas: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
smoothLineView = SmoothLineView(frame: mainDrawingCanvas.bounds)
self.view.addSubview(smoothLineView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func deleteCurrentCanvas(sender: AnyObject) {
mainDrawingCanvas.image = nil
}
}
完整的项目也可以找到:https://github.com/BananaSplitio/OpenSketch
【问题讨论】:
标签: ios swift uiimageview core cgcontext