public TabView() { defaultSelectionColor = UIDevice.CurrentDevice.CheckSystemVersion(7, 0) ? TabBar.TintColor : TabBar.SelectedImageTintColor; Delegate = new TabDelegate(); CustomizableViewControllers = null; }
private void SelectTab(TabPage tabPage) { if (tabControl1.InvokeRequired) { var d = new TabDelegate(SelectTab); tabControl1.Invoke(d, new object[] { tabPage }); } else { tabControl1.SelectTab(tabPage); } }
public void SetData(Transform parent, List <string> tabNameList, List <string> tabSubNameList, TabDelegate tabDelegate, int defaultIndex = 0) { //克隆 toggle Item for (int i = 0; i < tabNameList.Count - 1; i++) { Instantiate(_toggleItemOriginal, _toggleItemParent); } Toggle[] toggles = _toggleItemParent.GetComponentsInChildren <Toggle>(); transform.Find("TabBg/Decorate").gameObject.SetActive(toggles.Length <= 3); for (int i = 0; i < toggles.Length; i++) { int tempIndex = i; Text lable = toggles[tempIndex].transform.Find("Label").GetComponent <Text>(); lable.text = tabNameList[tempIndex]; GameObject effect = toggles[tempIndex].transform.Find("TabEffect").gameObject; toggles[tempIndex].group = _toggleGroup; toggles[tempIndex].onValueChanged.AddListener((isOn) => { if (isOn && (_currentIndex != tempIndex)) { _currentIndex = tempIndex; tabDelegate(tempIndex); } lable.color = isOn ? ColorOn : ColorOff; lable.fontSize = isOn ? FontSizeOn : FontSizeOff; effect.SetActive(isOn); toggles[tempIndex].transform.Find("LineLight").gameObject.SetActive(!isOn); if (tempIndex != 0) { toggles[tempIndex - 1].transform.Find("LineLight").gameObject.SetActive(!isOn); } }); } toggles[defaultIndex].isOn = true; }