123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // InviteViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/23.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class InviteViewController: BaseViewController {
- @IBOutlet weak var scrollView: UIScrollView!
- @IBOutlet weak var viewMenu1: UIView!
- @IBOutlet weak var viewMenu2: UIView!
- @IBOutlet weak var viewMenu3: UIView!
- @IBOutlet weak var viewBottomContent: UIView!
- @IBOutlet weak var viewBottom: UIView!
- @IBOutlet weak var imgShow: UIImageView!
- @IBOutlet weak var viewContent: UIView!
- var viewCode: ShareCodeView!
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "邀请好友"
- // let viewNav = (CommonViewUntils.getViewForXIB(xibName: "NavView") as! NavView);
- // viewNav.initView(title: "邀请好友") {[weak self] (index, str) in
- // if(index == 0)
- // {
- // self!.handleBack();
- // }
- // }
- // self.view.addSubview(viewNav)
- // viewNav.marginTop(top: 0);
- // viewContent.marginTop(top: -64, view: viewNav);
- //
- // imgShow.setSizeHeight(height: imgShow.width() / 1154 * 1249)
- initNavLeftBackButton()
- viewBottom.setSizeWidth(width: ScreenWidth)
- viewMenu1.setSizeWidth(width: ScreenWidth / 2)
- viewMenu2.setSizeWidth(width: ScreenWidth / 2)
- viewMenu2.marginLeft(left: 0, view: viewMenu1)
- imgShow.setSize(width: ScreenWidth, height: ScreenWidth / 1080 * 1920)
- scrollView.contentSize.height = ScreenWidth / 1080 * 1920
- let image2 = CommonBarCodeTools.setupQRCodeImage("\(RequestURL.userRecCode)?recCode=\(CommonValue.getUserRecCode())", image: UIImage(named: "icon"))
- imgShow.image = drawImages(imageArray: [UIImage(named: "sharefriend")!, image2])
- }
- //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: //
- CommonUMengShare.showSharedMenu(viewController: self, title: "立即注册,开启您的财富之旅", desc: "POS机办理,信用卡申请,积分换钱......", icon: UIImage(named: "icon")!, url: "\(RequestURL.userRecCode)?recCode=\(CommonValue.getUserRecCode())")
- break
- case 1002: //
- CommonUMengShare.showSharedMenu(viewController: self, img: imgShow.image!) { (index, _) in
- if index == 1 {
- } else {
- }
- }
- break
- case 1003: //
- break
- case 1004: //
- break
- case 1005: //
- break
- case 1006: //
- break
- default:
- break
- }
- }
- func drawImages(imageArray: [UIImage]) -> UIImage {
- // 1.1.图片的宽度
- let width: CGFloat = 1080
- // 1.2.图片的高度
- let height: CGFloat = 1920
- // 1.4.开始绘制图片的大小
- UIGraphicsBeginImageContext(CGSize(width: width, height: height))
- imageArray[0].draw(at: CGPoint(x: 0, y: 0))
- let codeSize = 267//imageArray[0].size.width / 4.2
- // imageArray[1].draw(in: CGRect(x: (imageArray[0].size.width - codeSize) / 2, y: imageArray[0].size.height - codeSize - 100 - codeSize, width: codeSize, height: codeSize));
- imageArray[1].draw(in: CGRect(x: 402, y: 1262, width: codeSize, height: codeSize))
- // // 1.5.设置一个变量用来获取UIImage的Y值
- // var imageY: CGFloat = 0
- // // 1.6.遍历图片的数组
- // for image in imageArray {
- // // 1.6.1.开始绘画图片
- // image.draw(at: CGPoint(x: 0, y: imageY))
- // // 1.6.2.自增每张图片的Y轴
- // imageY += image.size.height
- //
- // }
- // 1.7.获取已经绘制好的图片
- let drawImage = UIGraphicsGetImageFromCurrentImageContext()!
- // 1.8.结束绘制图片
- UIGraphicsEndImageContext()
- // 1.9.返回已经绘制的图片
- return drawImage
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- appDelegate.setNavigationBarHidden(isHidden: false)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "InviteViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|