我正在制作滑动手势识别器,特别是UIView
接收滑动,但我也希望它是透明的,使alpha=0
不会响应滑动。
这是添加手势的代码:
@IBOutlet weak var swipeView: UIView!
let swipeRec = UISwipeGestureRecognizer()
override func viewDidLoad() {
super.viewDidLoad()
swipeRec.addTarget(self, action: #selector(ViewController.swipedView))
swipeView.addGestureRecognizer(swipeRec)
swipeView.isUserInteractionEnabled = true
swipeRec.direction=UISwipeGestureRecognizerDirection.right
}
func swipedView(){
print("swiped")
}
答案 0 :(得分:0)
将视图的背景颜色设置为ClearColor而不是alpha设置为0。
swipeView.backgroundColor = UIColor.clearColor()