InviteViewController.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // InviteViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/3/23.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class InviteViewController: BaseViewController {
  10. @IBOutlet weak var scrollView: UIScrollView!
  11. @IBOutlet weak var viewMenu1: UIView!
  12. @IBOutlet weak var viewMenu2: UIView!
  13. @IBOutlet weak var viewMenu3: UIView!
  14. @IBOutlet weak var viewBottomContent: UIView!
  15. @IBOutlet weak var viewBottom: UIView!
  16. @IBOutlet weak var imgShow: UIImageView!
  17. @IBOutlet weak var viewContent: UIView!
  18. var viewCode: ShareCodeView!
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21. self.title = "邀请好友"
  22. // let viewNav = (CommonViewUntils.getViewForXIB(xibName: "NavView") as! NavView);
  23. // viewNav.initView(title: "邀请好友") {[weak self] (index, str) in
  24. // if(index == 0)
  25. // {
  26. // self!.handleBack();
  27. // }
  28. // }
  29. // self.view.addSubview(viewNav)
  30. // viewNav.marginTop(top: 0);
  31. // viewContent.marginTop(top: -64, view: viewNav);
  32. //
  33. // imgShow.setSizeHeight(height: imgShow.width() / 1154 * 1249)
  34. initNavLeftBackButton()
  35. viewBottom.setSizeWidth(width: ScreenWidth)
  36. viewMenu1.setSizeWidth(width: ScreenWidth / 2)
  37. viewMenu2.setSizeWidth(width: ScreenWidth / 2)
  38. viewMenu2.marginLeft(left: 0, view: viewMenu1)
  39. imgShow.setSize(width: ScreenWidth, height: ScreenWidth / 1080 * 1920)
  40. scrollView.contentSize.height = ScreenWidth / 1080 * 1920
  41. let image2 = CommonBarCodeTools.setupQRCodeImage("\(RequestURL.userRecCode)?recCode=\(CommonValue.getUserRecCode())", image: UIImage(named: "icon"))
  42. imgShow.image = drawImages(imageArray: [UIImage(named: "sharefriend")!, image2])
  43. }
  44. //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
  45. @IBAction func btnMenuClick(_ sender: AnyObject) {
  46. switch (sender as! UIButton).tag {
  47. case 1001: //
  48. CommonUMengShare.showSharedMenu(viewController: self, title: "立即注册,开启您的财富之旅", desc: "POS机办理,信用卡申请,积分换钱......", icon: UIImage(named: "icon")!, url: "\(RequestURL.userRecCode)?recCode=\(CommonValue.getUserRecCode())")
  49. break
  50. case 1002: //
  51. CommonUMengShare.showSharedMenu(viewController: self, img: imgShow.image!) { (index, _) in
  52. if index == 1 {
  53. } else {
  54. }
  55. }
  56. break
  57. case 1003: //
  58. break
  59. case 1004: //
  60. break
  61. case 1005: //
  62. break
  63. case 1006: //
  64. break
  65. default:
  66. break
  67. }
  68. }
  69. func drawImages(imageArray: [UIImage]) -> UIImage {
  70. // 1.1.图片的宽度
  71. let width: CGFloat = 1080
  72. // 1.2.图片的高度
  73. let height: CGFloat = 1920
  74. // 1.4.开始绘制图片的大小
  75. UIGraphicsBeginImageContext(CGSize(width: width, height: height))
  76. imageArray[0].draw(at: CGPoint(x: 0, y: 0))
  77. let codeSize = 267//imageArray[0].size.width / 4.2
  78. // imageArray[1].draw(in: CGRect(x: (imageArray[0].size.width - codeSize) / 2, y: imageArray[0].size.height - codeSize - 100 - codeSize, width: codeSize, height: codeSize));
  79. imageArray[1].draw(in: CGRect(x: 402, y: 1262, width: codeSize, height: codeSize))
  80. // // 1.5.设置一个变量用来获取UIImage的Y值
  81. // var imageY: CGFloat = 0
  82. // // 1.6.遍历图片的数组
  83. // for image in imageArray {
  84. // // 1.6.1.开始绘画图片
  85. // image.draw(at: CGPoint(x: 0, y: imageY))
  86. // // 1.6.2.自增每张图片的Y轴
  87. // imageY += image.size.height
  88. //
  89. // }
  90. // 1.7.获取已经绘制好的图片
  91. let drawImage = UIGraphicsGetImageFromCurrentImageContext()!
  92. // 1.8.结束绘制图片
  93. UIGraphicsEndImageContext()
  94. // 1.9.返回已经绘制的图片
  95. return drawImage
  96. }
  97. override func viewWillAppear(_ animated: Bool) {
  98. super.viewWillAppear(animated)
  99. appDelegate.setNavigationBarHidden(isHidden: false)
  100. }
  101. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  102. super.init(nibName: "InviteViewController", bundle: nil)
  103. }
  104. required init?(coder aDecoder: NSCoder) {
  105. fatalError("init(coder:) has not been implemented")
  106. }
  107. }