iOS如何制作如下所示的用户可调整大小的uiview?

时间:2016-05-03 12:32:06

标签: ios objective-c swift

我制作CAShapeLayer,并在该层的所有角落创建四个uiview。 并为所有这4个UIView添加平移手势。当任何人移动它时,Layer会根据它更新其帧。 任何的想法?我们将不胜感激。

        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

0 个答案:

没有答案