123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // IHClassGatewayView.swift
- // Inhealth
- //
- // Created by weclouds on 2020/8/19.
- // Copyright © 2020 weclouds. All rights reserved.
- //
- import UIKit
- import JXSegmentedView
- import JXPagingView
- protocol IHClassGatewayViewDelete : NSObjectProtocol {
-
- func changeCtr(tag : Int)
- }
- class IHClassGatewayView: UIView {
-
-
- var contentView : UIView?
- var bottomView : UIView?
- weak var delete : IHClassGatewayViewDelete?
-
-
- override init(frame: CGRect) {
- super.init(frame: frame)
- self.backgroundColor = .white
- self.setupUI()
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- }
- extension IHClassGatewayView {
- private func setupUI(){
- //h:811.5pt w: 376 ,h:74
-
- //设置底部的按键
- let bottomH = KSCREENHEIGHT * 74 / 811.5
- let bottomView = UIView.init(frame: CGRect.init(x: 0, y: KSCREENHEIGHT - bottomH, width: KSCREENWIDTH, height: bottomH))
- bottomView.backgroundColor = .white
- self.addSubview(bottomView)
- self.bottomView = bottomView
-
- //内容
- contentView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: KSCREENWIDTH, height: KSCREENHEIGHT - bottomH))
- self.addSubview(contentView!)
-
- let topLine = UIView.init(frame: CGRect.init(x: 0, y: 0.5, width: KSCREENWIDTH, height: 1))
- topLine.backgroundColor = .lightGray
- topLine.alpha = 0.5
- self.bottomView?.addSubview(topLine)
-
- //左边btn
- let classBtn = UIButton.init(frame: CGRect.init(x: 0, y: 4, width: KSCREENWIDTH * 0.5 - 0.5, height: bottomH * 0.6))
- classBtn.setImage(UIImage.init(named: "房间_未选中"), for: .normal)
- classBtn.setImage(UIImage.init(named: "房间_选中"), for: .selected)
- classBtn.setTitle("教室控制", for: .normal)
- classBtn.setTitleColor(UIColor.init(hexString: "#92A6C0"), for: .normal)
- classBtn.setTitleColor(UIColor.init(hexString: "##573F95"), for: .selected)
- classBtn.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 13)
- classBtn.isSelected = true
- classBtn.titleLabel?.font = UIFont.systemFont(ofSize: 12.0)
- classBtn.addTarget(self, action: #selector(choseClassCtr), for: .touchUpInside)
- classBtn.tag = 1
- bottomView.addSubview(classBtn)
-
- //中间线
- let line = UIView.init(frame: CGRect.init(x: classBtn.ly_maxX, y: 5, width: 1, height: bottomH * 0.5 - 6))
- line.alpha = 0.5
- line.backgroundColor = UIColor.init(hexString: "#C6CDD5")
- bottomView.addSubview(line)
-
- //右边
- let gatewayBtn = UIButton.init(frame: CGRect.init(x: line.ly_maxX, y: 5, width: KSCREENWIDTH * 0.5 - 0.5, height: bottomH * 0.6))
- gatewayBtn.setImage(UIImage.init(named: "设备_未选中"), for: .normal)
- gatewayBtn.setImage(UIImage.init(named: "设备_选中"), for: .selected)
- gatewayBtn.setTitle("网关配置", for: .normal)
- gatewayBtn.setTitleColor(UIColor.init(hexString: "#92A6C0"), for: .normal)
- gatewayBtn.setTitleColor(UIColor.init(hexString: "##573F95"), for: .selected)
- gatewayBtn.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 13)
- gatewayBtn.titleLabel?.font = UIFont.systemFont(ofSize: 12.0)
- gatewayBtn.addTarget(self, action: #selector(choseGatewayCtr), for: .touchUpInside)
- gatewayBtn.tag = 2
- bottomView.addSubview(gatewayBtn)
-
- }
- }
- extension IHClassGatewayView{
- @objc func choseClassCtr(btn : UIButton){
- btn.isSelected = !btn.isSelected
- for view in bottomView!.subviews {
- if view.tag == 2 {
- let gatewayBtn = view as! UIButton
- gatewayBtn.isSelected = !gatewayBtn.isSelected
- }
- }
- delete?.changeCtr(tag: btn.tag)
- }
-
- @objc func choseGatewayCtr(btn : UIButton){
- btn.isSelected = !btn.isSelected
- for view in bottomView!.subviews {
- if view.tag == 1 {
- let classBtn = view as! UIButton
- classBtn.isSelected = !classBtn.isSelected
- }
- }
- delete?.changeCtr(tag: btn.tag)
- }
- }
|