Reputation: 6359
This is the UIView I would like to have. Most of it would be hidden and could be dragged out ONLY by dragging the little visible part.
I thought about drawing my view up to let say 90% of its container and on the top, draw a little rectangle (the visible part) but then I faced 2 problems:
How can I achieve that?
Upvotes: 0
Views: 464
Reputation: 24714
You can use panGesture,in shouldReceiveTouch
check the touch point.
For example
class ViewController: UIViewController,UIGestureRecognizerDelegate {
var panGestureRecognizer:UIPanGestureRecognizer?
override func viewDidLoad() {
panGestureRecognizer = UIPanGestureRecognizer(target: self, action: "gestureRecognizer:");
self.view.userInteractionEnabled = true
self.view.addGestureRecognizer(panGestureRecognizer!)
}
func catchedPan(gesture:UIPanGestureRecognizer){
switch gesture.state{
case .Began:
case .Changed:
//Change frame here
case .Ended:
default:
}
}
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
if(gestureRecognizer == panGestureRecognizer){
let point = touch.locationInView(self.view);
if (point inside your area){
return true
}else{
return false
}
}
}
}
Upvotes: 1
Reputation: 385500
Override pointInside:withEvent:
to return false when the point is in the part of the view where you don't want to receive touches.
Upvotes: 1