12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // IHSignUpView.swift
- // Inhealth
- //
- // Created by weclouds on 2020/1/19.
- // Copyright © 2020 weclouds. All rights reserved.
- //
- import UIKit
- protocol IHSignUpViewDelegate : NSObjectProtocol {
- func signupToService(_ account:String?,passowrd:String?,passwordAgain:String?)
- func goPrivacyPolicy()
- }
- class IHSignUpView: UIView {
- weak var delegate:IHSignUpViewDelegate?
- @IBOutlet weak var accountTF: UITextField!
-
- @IBOutlet weak var passwordAgainTf: UITextField!
-
- @IBOutlet weak var pivacyBtn: UIButton!
-
- @IBOutlet weak var passwordTf: UITextField!
-
- @IBOutlet weak var selectedBtn: UIButton!
-
- @IBOutlet weak var confirmBtn: UIButton!
-
-
- override func awakeFromNib() {
- super.awakeFromNib()
- let privacyStr = "阅读并同意《用户隐私协议》"
- //富文本设置
- let text = NSMutableAttributedString(string: privacyStr)
- let attrs = [NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue,NSAttributedString.Key.foregroundColor : UIColor(hexString: "#657085") as Any] as [NSAttributedString.Key : Any]
- let attrs2 = [NSAttributedString.Key.foregroundColor: UIColor(hexString: "#657085")]
- text.addAttributes(attrs, range: NSRange(location: 13, length: text.length - 13))
- text.addAttributes(attrs2 as [NSAttributedString.Key : Any], range: NSRange(location: 0, length: text.length))
- pivacyBtn.setAttributedTitle(text, for: .normal)
- }
- deinit{
- log.debug("IHSignUpView销毁")
- }
- override func layoutSubviews() {
- super.layoutSubviews()
- //xib的frame需要在layoutsubViews中设置 不然有问题
- frame = CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: KSCREENHEIGHT - KNavBarHeight)
- }
-
- @IBAction func signupAction(_ sender: Any) {
- if let delegate = delegate {
- delegate.signupToService(self.accountTF.text, passowrd: self.passwordTf.text, passwordAgain: self.passwordAgainTf.text)
- }
- }
-
- @IBAction func privacyAction(_ sender: UIButton) {
- if let delegate = delegate {
- delegate.goPrivacyPolicy()
- }
- }
- @IBAction func selectedAction(_ sender: UIButton) {
- sender.isSelected = !sender.isSelected
- if sender.isSelected == true {
- confirmBtn.isEnabled = true
- // #05CFAB
- confirmBtn.backgroundColor = UIColor(hexString: "#573F95")
- }else{
- confirmBtn.isEnabled = false
- confirmBtn.backgroundColor = UIColor.lightGray
- }
-
- }
-
- }
|