// // MCNavBarSegmentValue1View.swift // HCQuanfangtong // // Created by Apple on 2022/9/22. // Copyright © 2022 Jyp. All rights reserved. // import UIKit import RxSwift import RxCocoa /// <#Description#> class MCNavBarSegmentValue1View: MCNavBarView { init(dataSource: [String], style: MCNavBarStyle? = nil, tap: ((Int)->Void)?, defaultSelectedIndex: Int = 0){ super.init(title: nil, subTitle: nil, style: style) self.contentView.addArrangedSubview(self.stackView) self.stackView.mas_makeConstraints { make in make?.height.offset()(KNavBarHeight) } for i in 0..Void)?{ didSet{ self.addTapAction {[unowned self] _ in if self.isSelected{ return } self.isSelected = true self.tap?() } } } init(name: String, style: MCNavBarStyle){ super.init(frame: CGRect.zero) self.style = style self.textLabel = UILabel.init(frame: CGRect.zero) self.textLabel.text = name self.textLabel.textAlignment = .center self.textLabel.textColor = style.styleForSubTitleColor self.textLabel.font = style.styleForTitleFont self.addSubview(self.textLabel) self.textLabel.mas_makeConstraints { make in make?.center.mas_equalTo()(self) } } /// 放大text func scaleText(){ if !self.isSelected{ self.isSelected = true } self.textLabel.transform = CGAffineTransform.identity self.textLabel.textColor = style.styleForTitleColor self.textLabel.font = style.styleForTitleFont self.textLabel.transform = CGAffineTransform.init(scaleX: self.style.styleForScaling, y: self.style.styleForScaling) } /// 还原text func identifyText(){ if self.isSelected{ self.isSelected = false } self.textLabel.transform = CGAffineTransform.identity self.textLabel.textColor = style.styleForScalingBeforeTitleColor } //MARK: - Private Property /// 内容 private var textLabel: UILabel! private var style: MCNavBarStyle! private var isSelected: Bool = false //MARK: - required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } }