0

I make CAShapeLayer, and create four uiview at all corner of that Layer. And add pan gesture to all these 4 UIView. when anyone of them moves it Layer update its frame according to it. Any idea? Efforts would be appreciated.

        topLeftControl = addControl(tl, pos: 1)
        topRightControl = addControl(tr, pos: 2)
        bottomLeftControl = addControl(bl, pos: 3)
        bottomRightControl = addControl(br, pos: 4)


   func addControl(p : CGPoint,pos : Int) -> (UIView)
    {

        var r : CGRect = CGRectZero
        r.origin = p
        r.size = CGSizeMake(15, 15)
        if(DeviceType.iPad)
        {
            r.size = CGSizeMake(55, 55)
        }


        let v = UIView.init(frame: r)

        v.layer.cornerRadius = v.frame.size.width / 2
        v.clipsToBounds = true
        v.backgroundColor = UIColor.whiteColor()
        v.userInteractionEnabled = true

        self.mainView.addSubview(v)


        let pan = UIPanGestureRecognizer.init(target: self, action: #selector(ViewController.dragMaker(_:)))
        v.addGestureRecognizer(pan)

        return v
    }

enter image description here

byJeevan
  • 3,728
  • 3
  • 37
  • 60
  • that is a view drawn by bezier path with some control points. – Teja Nandamuri May 03 '16 at 12:46
  • It should move within and parent view and also resizable using pan gesture. Do you have any idea about it? – Sagar Vaholiya May 03 '16 at 12:48
  • I would suggest creating a rectangular view with bezier path, and place circular buttons/circularView on the rectangular view and give each button/circularView a control point of the bezier path and redraw the view when those control points move! – Teja Nandamuri May 03 '16 at 12:51
  • see the answer in here:http://stackoverflow.com/questions/36954975/ios-game-center-baloons-menu/36955803?noredirect=1#comment61521585_36955803 – Teja Nandamuri May 03 '16 at 12:51
  • http://stackoverflow.com/a/17170490/4513993 But, this answer says it's better to use CAShapeLayer instead of UIBezierPath. – Sagar Vaholiya May 04 '16 at 06:15
  • The shape is made of bezier path, you can use shape layer with bezier path! – Teja Nandamuri May 04 '16 at 11:56

0 Answers0