NFCBlankVC.swift 2.24 KB
//
//  NFCBlankVC.swift
//  Twear
//
//  Created by yangbin on 2022/2/12.
//

import UIKit
import YYText
import MBProgressHUD

class NFCBlankVC: UIViewController {
    
    @IBOutlet weak var agreementLabel: YYLabel!
    @IBOutlet weak var agreementBtn: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = LocString("录入空白门卡")
    
        let str = LocString("我已阅读并同意") + LocString("《用户协议》")
        let text = NSMutableAttributedString(string: str, attributes: [.font: RegularFont(11), .foregroundColor: UIColor.rgbColorFromHex(0x808080)])
        let range = NSRange(text.string.range(of: LocString("《用户协议》"))!, in: "")

        text.yy_setTextHighlight(range, color: TintColor, backgroundColor: .clear) {[weak self] (containerView, text, range, rect) in
            let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "NFCAgreementVC")
            self?.navigationController?.pushViewController(vc, animated: true)
            print("123")
        }
        
//        text.yy_setTextUnderline(YYTextDecoration(style: .single, width: 1, color: UIColor.rgbColorFromHex(0xDD000B)), range: range)
        agreementLabel.attributedText = text
        // Do any additional setup after loading the view.
    }
    
    @IBAction func agreement(_ sender: UIButton) {
        sender.isSelected = !sender.isSelected
        sender.setImage(UIImage(named: sender.isSelected ? "selected" : "not_selected"), for: .normal)
    }
    
    @IBAction func createCard(_ sender: UIButton) {
        if !agreementBtn.isSelected {
            MBProgressHUD.show(LocString("请先同意用户协议"))
            return
        }
        let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "GenerateBlankVC")
        navigationController?.pushViewController(vc, animated: true)
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}