我正在执行以下命令,并显示以下结果:
class ViewController: UIViewController {
@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBOutlet weak var textSegmentedControl: UISegmentedControl!
@IBOutlet weak var translationSegmentedControl: UISegmentedControl!
@IBOutlet weak var firstLangText: UITextView!
@IBOutlet weak var secondLangText: UITextView!
@IBOutlet weak var thirdLangText: UITextView!
@IBOutlet weak var translationA: UITextView!
@IBOutlet weak var translationB: UITextView!
@IBOutlet weak var translationC: UITextView!
@IBOutlet weak var textInfo: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
style(control: segmentedControl)
segmentedControl.addTarget(self, action: #selector(updateMainSegmentedControl), for: .valueChanged)
textSegmentedControl.addTarget(self, action: #selector(updateTextSegmentedControl), for: .valueChanged)
translationSegmentedControl.addTarget(self, action: #selector(updateTranslationSegmentedControl), for: .valueChanged)
secondLangText.isHidden = true
thirdLangText.isHidden = true
translationSegmentedControl.isHidden = true
translationA.isHidden = true
translationB.isHidden = true
translationC.isHidden = true
}
//Mark: Stye SegmentControls & underlineBar
func style(control: UISegmentedControl) {
control.backgroundColor = .clear
control.tintColor = .clear
control.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 16), NSAttributedStringKey.foregroundColor: UIColor.secondaryColor], for: .normal)
control.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 16),NSAttributedStringKey.foregroundColor: UIColor.primaryColor], for: .selected)
}
@IBAction func textOrTranslationChange(_ sender: UISegmentedControl) {
switch segmentedControl.selectedSegmentIndex {
case 0:
textSegmentedControl.isHidden = false
translationSegmentedControl.isHidden = true
translationUnderlineBar.isHidden = true
firstLangText.isHidden = false
translationA.isHidden = true
textInfo.isHidden = true
case 1:
textSegmentedControl.isHidden = true
translationSegmentedControl.isHidden = false
firstLangText.isHidden = true
translationA.isHidden = false
textInfo.isHidden = true
case 2:
textSegmentedControl.isHidden = true
translationSegmentedControl.isHidden = true
firstLangText.isHidden = true
textInfo.isHidden = false
default:
break;
}
}
@IBAction func selectTextLanguage(_ sender: UISegmentedControl) {
switch textSegmentedControl.selectedSegmentIndex {
case 0:
firstLangText.isHidden = false
secondLangText.isHidden = true
thirdLangText.isHidden = true
translationA.isHidden = true
translationB.isHidden = true
translationC.isHidden = true
case 1:
firstLangText.isHidden = true
secondLangText.isHidden = false
thirdLangText.isHidden = true
translationA.isHidden = true
translationB.isHidden = true
translationC.isHidden = true
case 2:
firstLangText.isHidden = true
secondLangText.isHidden = true
thirdLangText.isHidden = false
translationA.isHidden = true
translationB.isHidden = true
translationC.isHidden = true
default:
break;
}
}
@IBAction func selectTranslationLanguage(_ sender: UISegmentedControl) {
switch translationSegmentedControl.selectedSegmentIndex {
case 0:
translationA.isHidden = false
translationB.isHidden = true
translationC.isHidden = true
firstLangText.isHidden = true
secondLangText.isHidden = true
thirdLangText.isHidden = true
case 1:
translationA.isHidden = true
translationB.isHidden = false
translationC.isHidden = true
firstLangText.isHidden = true
secondLangText.isHidden = true
thirdLangText.isHidden = true
case 2:
translationA.isHidden = true
translationB.isHidden = true
translationC.isHidden = false
firstLangText.isHidden = true
secondLangText.isHidden = true
thirdLangText.isHidden = true
default:
break;
}
}
我也想获取列的名称。我该怎么办?
答案 0 :(得分:0)
尝试Set heading on
-这将打开或关闭列标题。