我正在尝试让一些手势识别器在UIView上工作。在本例中,UIview是检索到的SVG图像,我使用的库是SwiftSVG。
但实际添加的图像是一个UIView,所以我认为这不是问题所在?
override func viewDidLoad() {
super.viewDidLoad()
let svgURL = URL(string: "https://openclipart.org/download/181651/manhammock.svg")!
let hammock = UIView(SVGURL: svgURL) { (svgLayer) in
svgLayer.fillColor = UIColor(red:0.8, green:0.16, blue:0.32, alpha:1.00).cgColor
svgLayer.resizeToFit(self.v2imageview.bounds)
}
hammock.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
hammock.isUserInteractionEnabled = true;
hammock.addGestureRecognizer(tap)
self.view.addSubview(hammock)
}
// function which is triggered when handleTap is called
@objc func handleTap(_ sender: UITapGestureRecognizer) {
print("Hello World")
}我怎样才能让识别器工作?
谢谢
发布于 2020-03-25 03:24:51
你需要设置一个框架
hammock.frame = ///或约束
https://stackoverflow.com/questions/60837902
复制相似问题