chenkaijie4ever / Single-hand-Sticker

A sticker view, just like MeiTuXiuXiu, which can be scaled、rotated and moved with single finger or both hands.
Apache License 2.0
50 stars 17 forks source link

cant move sticker when put into custom view #2

Closed hfzwhd closed 7 years ago

hfzwhd commented 7 years ago

hi i tried to put sticker in a custom uiview and uiimageview but the sticker stuck.cant move or scale. any idea to make this happened?

@IBOutlet weak var stickerCanvasView: UIView!
@IBOutlet weak var bgImage: UIImageView!

var animator: UIDynamicAnimator!
var selectedSticker: StickerView!

override func viewDidLoad() {
    super.viewDidLoad()

    bgImage.backgroundColor = UIColor.flatMint

    animator = UIDynamicAnimator(referenceView: view)
    //let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapBackground))
    //tapRecognizer.numberOfTapsRequired = 1
    //self.view.addGestureRecognizer(tapRecognizer)

    let sticker = StickerView(contentFrame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(150), height: CGFloat(150)), contentImage: UIImage(named: "sticker1"))

    sticker?.center = bgImage.center

    sticker?.enabledControl = true
    sticker?.enabledBorder = true
    sticker?.delegate = self
    sticker?.tag = 1

    bgImage.addSubview(sticker!)

    // Do any additional setup after loading the view.
}
chenkaijie4ever commented 7 years ago

Did u set your customView.userInteractionEnabled to YES ?

hfzwhd commented 7 years ago

oh my. now that settles it. thanks!