WallPaperHome722/WallpaperHD_Live/Home/V/WP_Preview.swift
2024-07-25 19:20:41 +08:00

52 lines
1.1 KiB
Swift

//
// 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!()
}
}
}