本文整理汇总了C#中UISegmentedControl类的典型用法代码示例。如果您正苦于以下问题:C# UISegmentedControl类的具体用法?C# UISegmentedControl怎么用?C# UISegmentedControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UISegmentedControl类属于命名空间,在下文中一共展示了UISegmentedControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommitView
public CommitView()
{
_viewSegment = new UISegmentedControl(new [] { "Changes", "Comments", "Approvals" });
_viewSegment.SelectedSegment = 0;
_viewSegment.ValueChanged += (sender, e) => Render();
_segmentBarButton = new UIBarButtonItem(_viewSegment);
}
示例2: ViewDidAppear
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear (animated);
this.View.BackgroundColor = UIColor.LightGray;
txtSpeak = new UITextView (new RectangleF (20, 50, this.View.Bounds.Width - 40, 100));
txtSpeak.Text = "Xamarin rocks!";
this.View.AddSubview (txtSpeak);
segAccent = new UISegmentedControl (new string[] {"US", "UK", "AUS" });
segAccent.Frame = new RectangleF(20,160,this.View.Bounds.Width - 40, 50);
segAccent.SelectedSegment = 0;
this.View.AddSubview (segAccent);
lblRate = new UILabel (new RectangleF (20, 230, 200, 20));
lblRate.Text = "Rate";
this.View.AddSubview (lblRate);
sldRate = new UISlider(new RectangleF(20,250,this.View.Bounds.Width - 40, 50));
sldRate.MinValue = 0;
sldRate.MaxValue = 100;
sldRate.Value = 75;
this.View.AddSubview (sldRate);
lblPitch = new UILabel (new RectangleF (20, 305, 200, 20));
lblPitch.Text = "Pitch";
this.View.AddSubview (lblPitch);
sldPitch = new UISlider(new RectangleF(20,325,this.View.Bounds.Width - 40, 50));
sldPitch.MinValue = 0;
sldPitch.MaxValue = 100;
sldPitch.Value = 75;
this.View.AddSubview (sldPitch);
btnSpeak = new UIButton (UIButtonType.RoundedRect);
btnSpeak.Frame = new RectangleF (100, 375, this.View.Bounds.Width - 200, 30);
btnSpeak.SetTitle ("Speak", UIControlState.Normal);
btnSpeak.TouchDown += (object sender, EventArgs e) => {
var speechSynthesizer = new AVSpeechSynthesizer ();
var speechUtterance =
new AVSpeechUtterance (txtSpeak.Text);
string lang = "en-US";
if (segAccent.SelectedSegment == 1) lang = "en-GB";
if (segAccent.SelectedSegment == 2) lang = "en-AU";
speechUtterance.Voice = AVSpeechSynthesisVoice.FromLanguage (lang);
speechUtterance.Rate = AVSpeechUtterance.MaximumSpeechRate * (sldRate.Value / 100);
speechUtterance.PitchMultiplier = 2.0f * (sldPitch.Value / 100);
speechSynthesizer.SpeakUtterance (speechUtterance);
};
this.View.AddSubview (btnSpeak);
}
示例3: GetCell
public override UITableViewCell GetCell (UITableView tv)
{
sc = new UISegmentedControl () {
BackgroundColor = UIColor.Clear,
Tag = 1,
};
sc.Selected = true;
sc.InsertSegment (choices [0].Text, 0, false);
sc.InsertSegment (choices [1].Text, 1, false);
sc.Frame = new RectangleF (570f, 8f, 150f, 26f);
sc.SelectedSegment = choices.FindIndex (e => e.Id == val.Id);
sc.AddTarget (delegate {
Value = choices [sc.SelectedSegment];
}, UIControlEvent.ValueChanged);
var cell = tv.DequeueReusableCell (CellKey);
// if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.AddSubview (sc);
// }
// else
// RemoveTag (cell, 1);
cell.TextLabel.Font = UIFont.BoldSystemFontOfSize (17);
//cell.Frame.Height = 44;
cell.TextLabel.Text = Caption;
if (this.IsMandatory)
cell.TextLabel.Text += "*";
return cell;
}
示例4: ViewDidLoad
public override void ViewDidLoad()
{
this.View.BackgroundColor = UIColor.LightGray;
guid = new NSUuid ("c5cf54e0-6dd8-45e9-91a3-a8cda2f41120");
bRegion = new CLBeaconRegion (guid, "beacon");
bRegion.NotifyEntryStateOnDisplay = true;
bRegion.NotifyOnEntry = true;
bRegion.NotifyOnExit = true;
base.ViewDidLoad ();
segBeacon = new UISegmentedControl (new string[] { "Beacon", "Finder" });
segBeacon.Frame = new RectangleF (20, 50, this.View.Bounds.Width - 40, 50);
segBeacon.SelectedSegment = 0;
button = new UIButton (UIButtonType.RoundedRect);
button.SetTitle ("Start!", UIControlState.Normal);
button.Frame = new RectangleF (50, 150, this.View.Bounds.Width - 100, 30);
button.TouchDown += HandleTouchDown;
this.View.AddSubview (segBeacon);
this.View.AddSubview (button);
}
示例5: Initialize
private void Initialize ()
{
Title = Locale.GetText ("");
_mapView = new MKMapView ();
_mapView.AutoresizingMask = UIViewAutoresizing.All;
_mapView.MapType = MKMapType.Standard;
_mapView.ShowsUserLocation = true;
_sgMapType = new UISegmentedControl ();
_sgMapType.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
_sgMapType.Opaque = true;
_sgMapType.Alpha = 0.75f;
_sgMapType.ControlStyle = UISegmentedControlStyle.Bar;
_sgMapType.InsertSegment ("Map", 0, true);
_sgMapType.InsertSegment ("Satellite", 1, true);
_sgMapType.InsertSegment ("Hybrid", 2, true);
_sgMapType.SelectedSegment = 0;
_sgMapType.ValueChanged += (s, e) => {
switch (_sgMapType.SelectedSegment) {
case 0:
_mapView.MapType = MKMapType.Standard;
break;
case 1:
_mapView.MapType = MKMapType.Satellite;
break;
case 2:
_mapView.MapType = MKMapType.Hybrid;
break;
}
};
}
示例6: FinishedLaunching
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
CGRect rect = UIScreen.MainScreen.ApplicationFrame;
//Create the OpenGL drawing view and add it to the window
drawingView = new PaintingView (new CGRect (rect.Location, rect.Size));
window.AddSubview (drawingView);
// Create a segmented control so that the user can choose the brush color.
var images = new[] {
UIImage.FromFile ("Images/Red.png"),
UIImage.FromFile ("Images/Yellow.png"),
UIImage.FromFile ("Images/Green.png"),
UIImage.FromFile ("Images/Blue.png"),
UIImage.FromFile ("Images/Purple.png")
};
if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
// we want the original colors, which is not the default iOS7 behaviour, so we need to
// replace them with ones having the right UIImageRenderingMode
for (int i = 0; i < images.Length; i++)
images [i] = images [i].ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal);
}
var segmentedControl = new UISegmentedControl (images);
// Compute a rectangle that is positioned correctly for the segmented control you'll use as a brush color palette
var frame = new CGRect (rect.X + LeftMarginPadding, rect.Height - PaletteHeight - TopMarginPadding,
rect.Width - (LeftMarginPadding + RightMarginPadding), PaletteHeight);
segmentedControl.Frame = frame;
// When the user chooses a color, the method changeBrushColor: is called.
segmentedControl.ValueChanged += ChangeBrushColor;
// Make sure the color of the color complements the black background
segmentedControl.TintColor = UIColor.DarkGray;
// Set the third color (index values start at 0)
segmentedControl.SelectedSegment = 2;
// Add the control to the window
window.AddSubview (segmentedControl);
// Now that the control is added, you can release it
// [segmentedControl release];
float r, g, b;
// Define a starting color
HslToRgb (2.0f / PaletteSize, PaintingView.Saturation, PaintingView.Luminosity, out r, out g, out b);
// Set the color using OpenGL
GL.Color4 (r, g, b, PaintingView.BrushOpacity);
// Look in the Info.plist file and you'll see the status bar is hidden
// Set the style to black so it matches the background of the application
app.SetStatusBarStyle (UIStatusBarStyle.BlackTranslucent, false);
// Now show the status bar, but animate to the style.
app.SetStatusBarHidden (false, true);
//Configure and enable the accelerometer
UIAccelerometer.SharedAccelerometer.UpdateInterval = 1.0f / AccelerometerFrequency;
UIAccelerometer.SharedAccelerometer.Acceleration += OnAccelerated;
window.MakeKeyAndVisible ();
return true;
}
示例7: ToolbarConfigurationItem
public UIBarButtonItem ToolbarConfigurationItem()
{
var current = model.Ordering;
toolbarControl = new UISegmentedControl();
toolbarControl.InsertSegment("name", 0, false);
toolbarControl.InsertSegment("time", 1, false);
toolbarControl.SelectedSegment = (current == BuildOrder.BuildName) ? 0 : 1;
toolbarControl.ControlStyle = UISegmentedControlStyle.Bar;
toolbarControl.Frame = new System.Drawing.RectangleF(0, 10, 100, 30);
toolbarControl.UserInteractionEnabled = true;
toolbarControl.ValueChanged += delegate {
switch (toolbarControl.SelectedSegment) {
case 0:
model.Ordering = BuildOrder.BuildName;
break;
default:
model.Ordering = BuildOrder.BuildTime;
break;
}
InvokeOnMainThread(UpdateUI);
};
return new UIBarButtonItem(toolbarControl);
}
示例8: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var camera = CameraPosition.FromCamera (37.78318, -122.403874, 18);
mapView = MapView.FromCamera (CGRect.Empty, camera);
mapView.BuildingsEnabled = false;
View = mapView;
// The possible floors that might be shown.
var types = new [] { "1", "2", "3" };
// Create a UISegmentedControl that is the navigationItem's titleView.
switcher = new UISegmentedControl (types) {
SelectedSegment = 0,
ControlStyle = UISegmentedControlStyle.Bar,
AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
};
NavigationItem.TitleView = switcher;
// Listen to touch events on the UISegmentedControl, force initial update.
switcher.ValueChanged += DidChangeSwitcher;
DidChangeSwitcher ();
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
View.BackgroundColor = CashflowTheme.SharedTheme.ViewBackground;
RCSwitchOnOff onSwitch = new RCSwitchOnOff (new RectangleF(72, 50, 76, 33));
onSwitch.IsOn = true;
scrollView.AddSubview (onSwitch);
RCSwitchOnOff offSwitch = new RCSwitchOnOff (new RectangleF(176, 50, 76, 33));
offSwitch.IsOn = false;
scrollView.AddSubview (offSwitch);
progressBar = new ADVPopoverProgressBar (new RectangleF(20, 135, 280, 23));
progressBar.SetProgress (0.5f);
scrollView.AddSubview (progressBar);
UISegmentedControl segment = new UISegmentedControl (new object[] {"Yes", "No"});
segment.Frame = new RectangleF (85, 245, 150, 42);
segment.SelectedSegment = 0;
scrollView.AddSubview (segment);
imageViewBg.Image = UIImage.FromFile ("Images/iPhone/black/revisions-bg.png").CreateResizableImage (
new UIEdgeInsets (50, 10, 200, 10));
}
示例10: CreateSegmentedControl
void CreateSegmentedControl ()
{
// _segmentedControl = new UISegmentedControl (new object[] { "one", "two", "three", "four" });
// _segmentedControl.ControlStyle = UISegmentedControlStyle.Bezeled;
// _segmentedControl.TintColor = UIColor.Black;
// _segmentedControl.SetImage (UIImage.FromFile ("Star.png"), 0);
// _segmentedControl.SelectedSegment = 0;
// _segmentedControl.Frame = new RectangleF (10, 10, View.Frame.Width - 20, 50);
_testLabel = new UILabel { Frame = new RectangleF (10, 200, 100, 50) };
_segmentedControl = new UISegmentedControl (new object[] { UIImage.FromFile ("Star.png"), "two", "three", "four" });
_segmentedControl.ControlStyle = UISegmentedControlStyle.Bezeled;
_segmentedControl.TintColor = UIColor.Black;
_segmentedControl.Frame = new RectangleF (10, 10, View.Frame.Width - 20, 50);
_segmentedControl.ValueChanged += (o, e) =>
{
_text = _segmentedControl.TitleAt (_segmentedControl.SelectedSegment) ?? "title not set";
_testLabel.Text = _text;
};
_segmentedControl.SelectedSegment = 0;
_segmentedControl.AddSubview (_testLabel);
View.AddSubview (_segmentedControl);
}
示例11: ToolbarConfigurationItem
public UIBarButtonItem ToolbarConfigurationItem()
{
var current = model.TimePeriod;
toolbarControl = new UISegmentedControl();
toolbarControl.InsertSegment("24h", 0, false);
toolbarControl.InsertSegment("week", 1, false);
toolbarControl.InsertSegment("month", 2, false);
toolbarControl.SelectedSegment = (current == TimePeriod.PastDay) ? 0 : (current == TimePeriod.PastWeek) ? 1 : 2;
toolbarControl.ControlStyle = UISegmentedControlStyle.Bar;
toolbarControl.Frame = new System.Drawing.RectangleF(0, 10, 130, 30);
toolbarControl.UserInteractionEnabled = true;
toolbarControl.ValueChanged += delegate {
switch (toolbarControl.SelectedSegment) {
case 0:
model.TimePeriod = TimePeriod.PastDay;
break;
case 1:
model.TimePeriod = TimePeriod.PastWeek;
break;
default:
model.TimePeriod = TimePeriod.PastMonth;
break;
}
ViewWillAppear(true);
};
return new UIBarButtonItem(toolbarControl);
}
示例12: BuildControlsDialogViewController
DialogViewController BuildControlsDialogViewController()
{
var segmentControl = new UISegmentedControl (new string[] {
"One", "Two", "Three"
});
segmentControl.Frame = new RectangleF (5, 5, 280, 35);
segmentControl.SetEnabled (true, 1);
var root = new BTRootElement ("Controls Dialog View Controller") {
new BTBackgroundImageSection("Controls")
{
new FloatElement(Resources.TempIcon, Resources.TempIcon, 0.5f),
WrapInView(new UIProgressView (new RectangleF (10, 20, 280, 18)) { Progress = 0.75f }),
new ActivityElement(),
//new BadgeElement("")
new BooleanElement("Boolean Element", true),
//new BTBooleanElement("BTBooleanElement", true),
//new BooleanImageElement("BoolImage", true, //)
WrapInView (segmentControl),
}
};
return new BTDialogViewController (root, false);
}
示例13: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
_viewSegment = new UISegmentedControl(new object[] { "Open".t(), "Closed".t(), "Custom".t() });
_segmentBarButton = new UIBarButtonItem(_viewSegment);
_segmentBarButton.Width = View.Frame.Width - 10f;
ToolbarItems = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _segmentBarButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) };
var vm = (MyIssuesViewModel)ViewModel;
vm.Bind(x => x.SelectedFilter, x =>
{
if (x == 2)
{
ShowFilterController(new CodeHub.iOS.Views.Filters.MyIssuesFilterViewController(vm.Issues));
}
// If there is searching going on. Finish it.
FinishSearch();
});
BindCollection(vm.Issues, CreateElement);
var set = this.CreateBindingSet<MyIssuesView, MyIssuesViewModel>();
set.Bind(_viewSegment).To(x => x.SelectedFilter);
set.Apply();
}
示例14: Styles
public Styles()
{
this.SfGrid = new SfDataGrid ();
viewmodel = new GridGettingStartedViewModel ();
this.SfGrid.AutoGeneratingColumn += GridAutoGenerateColumns;
this.SfGrid.ItemsSource = viewmodel.OrdersInfo;
this.SfGrid.ShowRowHeader = false;
this.SfGrid.HeaderRowHeight = 45;
this.SfGrid.RowHeight = 45;
this.SfGrid.SelectionMode = SelectionMode.Multiple;
this.SfGrid.GridViewCreated += SfGrid_GridViewCreated;
this.SfGrid.GroupColumnDescriptions.Add (new GroupColumnDescription(){ColumnName ="CustomerID"});
this.SfGrid.AlternatingRowColor = UIColor.FromRGB (25, 25, 25);
segmentControl = new UISegmentedControl();
segmentControl.ControlStyle = UISegmentedControlStyle.Bezeled;
segmentControl.InsertSegment("Dark", 0,true);
segmentControl.InsertSegment("Blue", 1, true);
segmentControl.InsertSegment("Red", 2, true);
segmentControl.InsertSegment("Green", 3, true);
segmentControl.SelectedSegment = 0;
segmentControl.ValueChanged += SegmentControl_ValueChanged;
this.control = this;
this.AddSubview (segmentControl);
this.AddSubview (SfGrid);
}
示例15: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
_tipLabel = new UILabel ();
_calculateButton = new UIButton (UIButtonType.Custom);
_priceField = new UITextField ();
_tipPercentages = new UISegmentedControl ();
View.AddSubview (_priceField);
View.AddSubview (_calculateButton);
View.AddSubview (_tipLabel);
View.AddSubview (_tipPercentages);
_priceField.TranslatesAutoresizingMaskIntoConstraints = false;
_priceField.KeyboardType = UIKeyboardType.DecimalPad;
_priceField.BorderStyle = UITextBorderStyle.RoundedRect;
_priceField.Placeholder = "Enter Total Amount:";
View.AddConstraint (NSLayoutConstraint.Create (View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _priceField, NSLayoutAttribute.TopMargin, 1, -28));
View.AddConstraint (NSLayoutConstraint.Create (View, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, _priceField, NSLayoutAttribute.CenterX, 1, 0));
View.AddConstraint (NSLayoutConstraint.Create (View, NSLayoutAttribute.Width, NSLayoutRelation.Equal, _priceField, NSLayoutAttribute.Width, 1, 40));
View.AddConstraint (NSLayoutConstraint.Create (_priceField, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 35));
_calculateButton.TranslatesAutoresizingMaskIntoConstraints = false;
_calculateButton.SetTitle ("Calculate", UIControlState.Normal);
_calculateButton.SetTitleColor (UIColor.White, UIControlState.Normal);
_calculateButton.SetTitleColor (UIColor.Blue, UIControlState.Highlighted);
_calculateButton.BackgroundColor = UIColor.Green;
_calculateButton.TouchUpInside += (sender, e) => CalculateCurrentTip();
View.AddConstraint(NSLayoutConstraint.Create(_priceField, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _calculateButton, NSLayoutAttribute.Top, 1, -8));
View.AddConstraint (NSLayoutConstraint.Create (_calculateButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0));
View.AddConstraint (NSLayoutConstraint.Create (_calculateButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, -40));
_tipPercentages.TranslatesAutoresizingMaskIntoConstraints = false;
_tipPercentages.InsertSegment ("10%", 0, false);
_tipPercentages.InsertSegment ("15%", 1, false);
_tipPercentages.InsertSegment ("20%", 2, false);
_tipPercentages.InsertSegment ("25%", 3, false);
_tipPercentages.SelectedSegment = 2;
_tipPercentages.ValueChanged += (sender, e) => CalculateCurrentTip();
View.AddConstraint (NSLayoutConstraint.Create (_calculateButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _tipPercentages, NSLayoutAttribute.Top, 1, -8));
View.AddConstraint (NSLayoutConstraint.Create (_tipPercentages, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, -40));
View.AddConstraint (NSLayoutConstraint.Create (_tipPercentages, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0));
_tipLabel.TranslatesAutoresizingMaskIntoConstraints = false;
_tipLabel.TextColor = UIColor.Blue;
_tipLabel.Text = string.Format (TipFormat, 0);
_tipLabel.TextAlignment = UITextAlignment.Center;
View.AddConstraint (NSLayoutConstraint.Create (_tipLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _tipPercentages, NSLayoutAttribute.Bottom, 1, 8));
View.AddConstraint (NSLayoutConstraint.Create (_tipLabel, NSLayoutAttribute.Width, NSLayoutRelation.Equal, View, NSLayoutAttribute.Width, 1, -40));
View.AddConstraint (NSLayoutConstraint.Create (_tipLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0));
View.BackgroundColor = UIColor.Yellow;
View.AddGestureRecognizer (new UITapGestureRecognizer (() => _priceField.ResignFirstResponder ()));
}