//
//  WP_Preview.swift
//  WallpaperHD_Live


import UIKit


class WP_Preview: UIView {

    var touchBlock:(()->())?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        commonInit()

    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    
    }
    
    private func commonInit() {
          guard let view = loadViewFromNib() else { return }
          view.frame = bounds
          addSubview(view)
        
      }
    private func loadViewFromNib() -> UIView? {
          let nib = UINib(nibName: "WP_Preview", bundle: nil)
          return nib.instantiate(withOwner: self, options: nil).first as? UIView
      }
    

    @IBAction func hidView(_ sender: UIButton) {
        UIView.animate(withDuration: 1.0, animations: {
            self.frame.origin.x = -self.frame.width
        }) { (finished) in
            // 移除自定义视图
            self.removeFromSuperview()
        }
        
        if self.touchBlock != nil{
            self.touchBlock!()
            
        }
    }

    
}
