SHARE
TWEET

Untitled

a guest Jun 16th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class XXXX: UIView {
  2.     var url: String
  3.     var image: UIImage? = nil
  4.     var sadView: UIImageView = {
  5.         let v = UIImageView()
  6.         v.autoresizingMask = .flexibleWidth
  7.         return v
  8.     }()
  9.  
  10.  
  11.     convenience init(frame: CGRect, url: String, callback: @escaping (_: UIImage) -> Void ) {
  12.         self.init(frame: frame)
  13.         self.url = url
  14.         if let tryImage = EFQRCode.generate(
  15.             content: url,
  16.             watermark: UIImage(named: "XXXXXXX")?.toCGImage()
  17.             ) {
  18.             print("Create QRCode image success: (tryImage)")
  19.             self.image = UIImage(cgImage: tryImage)
  20.             self.sadView.image = self.image
  21.         } else {
  22.             print("Create QRCode image failed!")
  23.         }
  24.     }
  25.  
  26.     override init(frame: CGRect) {
  27.         self.url = ""
  28.         super.init(frame: frame)
  29.         addSubview(sadView)
  30.         constrain(sadView, self) { sadView, superView in
  31.             sadView.centerX == superView.centerX
  32.             sadView.width == 340
  33.             sadView.height == 340
  34.             sadView.centerY == superView.centerY
  35.         }        
  36.     }
  37.  
  38.     required init?(coder aDecoder: NSCoder) {
  39.         fatalError("init(coder:) has not been implemented")
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top