protected override void Dispose(bool disposing) { ClearScrollViewSubLayers(); SelectionIndicatorBoxLayer.Dispose(); SelectionIndicatorStripLayer.Dispose(); SelectionIndicatorArrowLayer.Dispose(); base.Dispose(disposing); }
protected override void Dispose(bool disposing) { ClearScrollViewSubLayers(); SelectionIndicatorBoxLayer.Dispose(); SelectionIndicatorStripLayer.Dispose(); SelectionIndicatorArrowLayer.Dispose(); foreach (var view in Subviews) { view.RemoveFromSuperview(); view.Dispose(); } base.Dispose(disposing); }
private void SetSelectedSegmentIndex(int index, bool animated = false, bool notify = false) { SelectedIndex = index; SetNeedsDisplay(); if (index == -1) { SelectionIndicatorArrowLayer.RemoveFromSuperLayer(); SelectionIndicatorStripLayer.RemoveFromSuperLayer(); SelectionIndicatorBoxLayer.RemoveFromSuperLayer(); } else { ScrollToSelectedSegmentIndex(animated); if (animated) { if (SelectionStyle == HMSegmentedControlSelectionStyle.Arrow) { AddScrollViewSubLayer(SelectionIndicatorArrowLayer); SetSelectedSegmentIndex(index, false, true); return; } else { if (SelectionIndicatorStripLayer.SuperLayer == null) { AddScrollViewSubLayer(SelectionIndicatorStripLayer); if (SelectionStyle == HMSegmentedControlSelectionStyle.Box && SelectionIndicatorBoxLayer.SuperLayer == null) { InsertScrollViewSubLayer(SelectionIndicatorBoxLayer, 0); } SetSelectedSegmentIndex(index, false, true); } } if (notify) { NotifyForSegmentChange(index); } SelectionIndicatorArrowLayer.Actions = new NSDictionary(); SelectionIndicatorStripLayer.Actions = new NSDictionary(); SelectionIndicatorBoxLayer.Actions = new NSDictionary(); CATransaction.Begin(); CATransaction.AnimationDuration = 0.15f; CATransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear); SetArrowFrame(); SelectionIndicatorBoxLayer.Frame = FrameForSelectionIndicator(); SelectionIndicatorStripLayer.Frame = FrameForSelectionIndicator(); SelectionIndicatorBoxLayer.Frame = FrameForFillerSelectionIndicator(); CATransaction.Commit(); } else { var newActions = new NSMutableDictionary(); newActions.Add(new NSString("position"), NSNull.Null); newActions.Add(new NSString("bounds"), NSNull.Null); SelectionIndicatorArrowLayer.Actions = newActions; SelectionIndicatorStripLayer.Actions = newActions; SelectionIndicatorBoxLayer.Actions = newActions; SelectionIndicatorStripLayer.Frame = FrameForSelectionIndicator(); SelectionIndicatorBoxLayer.Frame = FrameForFillerSelectionIndicator(); if (notify) { NotifyForSegmentChange(index); } } } }