本文整理汇总了C#中UIButton.SetTitle方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.SetTitle方法的具体用法?C# UIButton.SetTitle怎么用?C# UIButton.SetTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIButton
的用法示例。
在下文中一共展示了UIButton.SetTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.BackgroundColor = Theme.PrimaryNavigationBarColor;
var welcomeViewController = new WelcomeViewController();
welcomeViewController.WantsToDimiss += OnWantsToDismiss;
var pages = new UIViewController[]
{
new CardPageViewController(new AboutViewController()),
new CardPageViewController(new PromoteView()),
new CardPageViewController(new GoProViewController()),
new CardPageViewController(new FeedbackViewController()),
new CardPageViewController(welcomeViewController),
};
var welcomePageViewController = new UIPageViewController(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal);
welcomePageViewController.DataSource = new PageDataSource(pages);
welcomePageViewController.SetViewControllers(new [] { pages[0] }, UIPageViewControllerNavigationDirection.Forward, true, null);
welcomePageViewController.View.Frame = new CoreGraphics.CGRect(0, 0, View.Frame.Width, View.Frame.Height);
welcomePageViewController.View.AutoresizingMask = UIViewAutoresizing.All;
AddChildViewController(welcomePageViewController);
Add(welcomePageViewController.View);
var nextButton = new UIButton(UIButtonType.Custom);
nextButton.SetTitle("Next", UIControlState.Normal);
nextButton.TintColor = UIColor.White;
nextButton.TitleLabel.Font = UIFont.SystemFontOfSize(14f);
nextButton.Frame = new CoreGraphics.CGRect(View.Frame.Width - 50f, View.Frame.Height - 28f, 40f, 20f);
nextButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin;
Add(nextButton);
var transitionAction = new Action<UIViewController>(e => {
var isLast = pages.Last() == e;
//nextButton.Enabled = !isLast;
UIView.Transition(nextButton, 0.25f, UIViewAnimationOptions.TransitionCrossDissolve,
() => nextButton.SetTitle(isLast ? "Done" : "Next", UIControlState.Normal), null);
});
welcomePageViewController.WillTransition += (sender, e) => transitionAction(e.PendingViewControllers[0]);
nextButton.TouchUpInside += (sender, e) => {
var currentViewController = welcomePageViewController.ViewControllers[0];
var nextViewController = welcomePageViewController.DataSource.GetNextViewController(welcomePageViewController, currentViewController);
if (nextViewController != null)
{
transitionAction(nextViewController);
welcomePageViewController.SetViewControllers(new [] { nextViewController }, UIPageViewControllerNavigationDirection.Forward, true, null);
}
else
{
OnWantsToDismiss();
}
};
}
示例2: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.BackgroundColor = UIColor.White;
var gameNameLabel = new UILabel(new RectangleF(10, 80, View.Frame.Width - 20, 20));
gameNameLabel.Text = "Spartakiade Quiz";
View.AddSubview(gameNameLabel);
var playname = new UITextView(new RectangleF(10, 110, View.Frame.Width - 20, 20));
playname.BackgroundColor = UIColor.Brown;
View.AddSubview(playname);
var btnStartGame = new UIButton(new RectangleF(10, 140, View.Frame.Width - 20, 20));
btnStartGame.SetTitle("Start game", UIControlState.Normal);
btnStartGame.BackgroundColor = UIColor.Blue;
btnStartGame.TouchUpInside += delegate
{
NavigationController.PushViewController(new PlayGameController(playname.Text), true);
};
View.AddSubview(btnStartGame);
}
示例3: ViewDidLoad
public override void ViewDidLoad()
{
View = new UIView(){ BackgroundColor = UIColor.White};
base.ViewDidLoad();
var label = new UILabel(new RectangleF(10, 10, 300, 40));
Add(label);
var textField = new UITextField(new RectangleF(10, 50, 300, 40));
Add(textField);
var button = new UIButton(UIButtonType.RoundedRect);
button.SetTitle("Click Me", UIControlState.Normal);
button.Frame = new RectangleF(10, 90, 300, 40);
Add(button);
var button2 = new UIButton(UIButtonType.RoundedRect);
button2.SetTitle("Go Second", UIControlState.Normal);
button2.Frame = new RectangleF(10, 130, 300, 40);
Add(button2);
var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
set.Bind(label).To(vm => vm.Hello);
set.Bind(textField).To(vm => vm.Hello);
set.Bind(button).To(vm => vm.MyCommand);
set.Bind(button2).To(vm => vm.GoSecondCommand);
set.Apply();
}
示例4: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "Buttons";
View.BackgroundColor = UIColor.White;
buttonRect = UIButton.FromType(UIButtonType.RoundedRect);
buttonRect.SetTitle ("Click me", UIControlState.Normal);
buttonRect.SetTitle ("Clicking me", UIControlState.Highlighted);
buttonRect.SetTitle ("Disabled", UIControlState.Disabled);
buttonRect.SetTitleColor (UIColor.LightGray, UIControlState.Disabled);
buttonCustom = UIButton.FromType(UIButtonType.RoundedRect);
buttonCustom.SetTitle ("Button", UIControlState.Normal);
buttonCustom.SetTitle ("Button!!!!", UIControlState.Highlighted);
buttonCustom.Font = UIFont.FromName ("Helvetica-BoldOblique", 26f);
buttonCustom.SetTitleColor (UIColor.Brown, UIControlState.Normal);
buttonCustom.SetTitleColor (UIColor.Yellow, UIControlState.Highlighted);
buttonCustom.SetTitleShadowColor (UIColor.DarkGray, UIControlState.Normal);
buttonRect.Frame = new CGRect(160, 100, 140, 40);
buttonCustom.Frame = new CGRect(160, 180, 140, 60);
buttonRect.TouchUpInside += HandleTouchUpInside;
buttonCustom.TouchUpInside += HandleTouchUpInside;
View.AddSubview (buttonRect);
View.AddSubview (buttonCustom);
}
示例5: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
View.BackgroundColor = UIColor.Gray;
// Perform any additional setup after loading the view, typically from a nib.
viewModel = new Model ();
UILabel lbl = new UILabel (new RectangleF(0,0,320, 50));
lbl.Text = viewModel.Text;
lbl.AdjustsFontSizeToFitWidth = true;
UITextView et = new UITextView (new RectangleF (0, 60, 320, 50));
et.Text = viewModel.Text;
et.Changed += (object sender, EventArgs e) => {
viewModel.Text = et.Text;
};
UIButton btn = new UIButton(new RectangleF(0, 120, 320, 50));
btn.SetTitle(viewModel.TimesString, UIControlState.Normal);
btn.TouchUpInside += (s,e) => viewModel.ClickEvent.Execute(null);
btn.ShowsTouchWhenHighlighted = true;
viewModel.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
{
if (e.PropertyName == "Text")
lbl.Text = viewModel.Text;
else if (e.PropertyName == "TimesString")
btn.SetTitle(viewModel.TimesString, UIControlState.Normal);
};
View.Add (lbl);
View.Add (et);
View.Add (btn);
}
示例6: CustomRecCell
public CustomRecCell(NSString cellId)
: base(UITableViewCellStyle.Default, cellId)
{
SelectionStyle = UITableViewCellSelectionStyle.Gray;
fileNameLabel = new UILabel () {
Font = UIFont.FromName("AmericanTypewriter", 15f),
BackgroundColor = UIColor.Clear
};
playerPlayButton = new UIButton ();
playerPlayButton.SetTitle("Play", UIControlState.Normal);
playerPlayButton.SetTitle("Playing", UIControlState.Selected);
playerPlayButton.Font = UIFont.FromName ("AmericanTypewriter", 15f);
playerPlayButton.TouchUpInside += playerPlayButtonTouchUpInside_Event;
playerStopButton = new UIButton ();
playerStopButton.SetTitle("Stop", UIControlState.Normal);
playerStopButton.Font = UIFont.FromName ("AmericanTypewriter", 15f);
playerStopButton.TouchUpInside += playerStopButtonTouchUpInside_Event;
progressBar = new UISlider ();
progressBar.Enabled = false;
progressBar.SetThumbImage (UIImage.FromBundle("Images/slider_thumb"), UIControlState.Normal);
ContentView.Add (fileNameLabel);
ContentView.Add (playerPlayButton);
ContentView.Add (playerStopButton);
ContentView.Add (progressBar);
}
示例7: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.Frame = UIScreen.MainScreen.Bounds;
View.BackgroundColor = UIColor.White;
View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
button = UIButton.FromType(UIButtonType.RoundedRect);
button.Frame = new RectangleF(
View.Frame.Width / 2 - buttonWidth / 2,
View.Frame.Height / 2 - buttonHeight / 2,
buttonWidth,
buttonHeight);
button.SetTitle("Click me", UIControlState.Normal);
button.TouchUpInside += (object sender, EventArgs e) =>
{
button.SetTitle(String.Format("clicked {0} times", numClicks++), UIControlState.Normal);
};
button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin |
UIViewAutoresizing.FlexibleBottomMargin;
View.AddSubview(button);
}
示例8: AddSiteUrl
public void AddSiteUrl(RectangleF frame)
{
url = UIButton.FromType(UIButtonType.Custom);
url.LineBreakMode = UILineBreakMode.TailTruncation;
url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
url.TitleShadowOffset = new SizeF(0, 1);
url.SetTitleColor(UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal);
url.SetTitleColor(UIColor.Red, UIControlState.Highlighted);
url.SetTitleShadowColor(UIColor.White, UIControlState.Normal);
url.AddTarget(delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside);
// Autosize the bio URL to fit available space
var size = _urlSize;
var urlFont = UIFont.BoldSystemFontOfSize(size);
var urlSize = new NSString(_bio.Url).StringSize(urlFont);
var available = Util.IsPad() ? 400 : 185; // Util.IsRetina() ? 185 : 250;
while(urlSize.Width > available)
{
urlFont = UIFont.BoldSystemFontOfSize(size--);
urlSize = new NSString(_bio.Url).StringSize(urlFont);
}
url.Font = urlFont;
url.Frame = new RectangleF ((float)_left, (float)70, (float)(frame.Width - _left), (float)size);
url.SetTitle(_bio.Url, UIControlState.Normal);
url.SetTitle(_bio.Url, UIControlState.Highlighted);
AddSubview(url);
}
示例9: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
#region UI Controls (you could do this in XIB if you want)
saveButton = UIButton.FromType(UIButtonType.RoundedRect);
saveButton.Frame = new RectangleF(10,10,145,50);
saveButton.SetTitle("Save", UIControlState.Normal);
saveButton.SetTitle("waiting...", UIControlState.Disabled);
saveButton.Enabled = false;
doneSwitch = new UISwitch();
doneSwitch.Frame = new RectangleF(180, 25, 145, 50);
doneSwitch.Enabled = false;
doneLabel = new UILabel();
doneLabel.Frame = new RectangleF(200, 10, 145, 15);
doneLabel.Text = "Done?";
titleText = new UITextView(new RectangleF(10, 70, 300, 40));
titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
titleText.Editable = true;
titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
descriptionText.BackgroundColor = UIColor.FromRGB(240,240,240);
descriptionText.Editable = true;
descriptionText.ScrollEnabled = true;
descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;
// Add the controls to the view
this.Add(saveButton);
this.Add(doneLabel);
this.Add(doneSwitch);
this.Add(descriptionText);
this.Add(titleText);
#endregion
saveButton.TouchUpInside += (sender, e) => {
doc.TheTask.Title = titleText.Text;
doc.TheTask.Description = descriptionText.Text;
doc.TheTask.IsDone = doneSwitch.On;
doc.UpdateChangeCount (UIDocumentChangeKind.Done); // tell UIDocument it needs saving
descriptionText.ResignFirstResponder (); // hide keyboard
titleText.ResignFirstResponder ();
};
LoadData ();
NSNotificationCenter.DefaultCenter.AddObserver (this
, new Selector("dataReloaded:")
, new NSString("taskModified"),
null);
}
示例10: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "Save to Album";
View.BackgroundColor = UIColor.White;
cameraButton = UIButton.FromType (UIButtonType.RoundedRect);
cameraButton.Frame = new CGRect(10, 20, 100,40);
cameraButton.SetTitle ("Camera", UIControlState.Normal);
cameraButton.TouchUpInside += (sender, e) => {
TweetStation.Camera.TakePicture (this, (obj) =>{
// https://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html#//apple_ref/occ/intfm/UIImagePickerControllerDelegate/imagePickerController:didFinishPickingMediaWithInfo:
var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
var meta = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
// This bit of code saves to the Photo Album with metadata
ALAssetsLibrary library = new ALAssetsLibrary();
library.WriteImageToSavedPhotosAlbum (photo.CGImage, meta, (assetUrl, error) =>{
Console.WriteLine ("assetUrl:"+assetUrl);
});
// This bit of code does basic 'save to photo album', doesn't save metadata
// var someImage = UIImage.FromFile("someImage.jpg");
// someImage.SaveToPhotosAlbum ((image, error)=> {
// var o = image as UIImage;
// Console.WriteLine ("error:" + error);
// });
// This bit of code saves to the application's Documents directory, doesn't save metadata
// var documentsDirectory = Environment.GetFolderPath
// (Environment.SpecialFolder.Personal);
// string jpgFilename = System.IO.Path.Combine (documentsDirectory, "Photo.jpg");
// NSData imgData = photo.AsJPEG();
// NSError err = null;
// if (imgData.Save(jpgFilename, false, out err))
// {
// Console.WriteLine("saved as " + jpgFilename);
// } else {
// Console.WriteLine("NOT saved as" + jpgFilename + " because" + err.LocalizedDescription);
// }
});
};
View.Add (cameraButton);
if (!UIImagePickerController.IsSourceTypeAvailable (UIImagePickerControllerSourceType.Camera)) {
cameraButton.SetTitle ("No camera", UIControlState.Disabled);
cameraButton.SetTitleColor (UIColor.Gray, UIControlState.Disabled);
cameraButton.Enabled = false;
}
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
#region UI layout stuff, not relevant to example
Title = "Consumable Products";
View.BackgroundColor = UIColor.White;
buy5Button = UIButton.FromType (UIButtonType.RoundedRect);
buy5Button.SetTitle ("loading...", UIControlState.Disabled);
buy5Button.SetTitleColor(UIColor.Gray, UIControlState.Disabled);
buy5Button.SetTitle ("Buy...", UIControlState.Normal);
buy5Button.Enabled = false;
buy10Button = UIButton.FromType (UIButtonType.RoundedRect);
buy10Button.SetTitle ("loading...", UIControlState.Disabled);
buy10Button.SetTitleColor(UIColor.Gray, UIControlState.Disabled);
buy10Button.SetTitle ("Buy...", UIControlState.Normal);
buy10Button.Enabled = false;
buy5Title = new UILabel(new RectangleF(10, 10, 300, 30));
buy5Title.Font = UIFont.BoldSystemFontOfSize(18f);
buy5Description = new UILabel(new RectangleF(10, 40, 300, 30));
buy5Button.Frame = new RectangleF(10, 80, 200, 40);
buy10Title = new UILabel(new RectangleF(10, 140, 300, 30));
buy10Title.Font = UIFont.BoldSystemFontOfSize(18f);
buy10Description = new UILabel(new RectangleF(10, 170, 300, 30));
buy10Button.Frame = new RectangleF(10, 210, 200, 40);
balanceLabel = new UILabel(new Rectangle(10, 280, 300, 40));
balanceLabel.Font = UIFont.BoldSystemFontOfSize(24f);
infoLabel = new UILabel(new RectangleF(10, 340, 300, 80));
infoLabel.Lines = 3;
infoLabel.Text = Footer;
View.AddSubview (buy5Button);
View.AddSubview (buy5Title);
View.AddSubview (buy5Description);
View.AddSubview (buy10Button);
View.AddSubview (buy10Title);
View.AddSubview (buy10Description);
View.AddSubview (balanceLabel);
View.AddSubview (infoLabel);
#endregion
buy5Button.TouchUpInside += (sender, e) => {
iap.PurchaseProduct (Buy5ProductId);
};
buy10Button.TouchUpInside += (sender, e) => {
iap.PurchaseProduct (Buy10ProductId);
};
}
示例12: TappedDeepButton
partial void TappedDeepButton (UIButton sender)
{
// switch network to be used between the deep and the single layered
if (deep) {
sender.SetTitle ("Use Deep Net", UIControlState.Normal);
runningNet = neuralNetwork;
} else {
sender.SetTitle ("Use Single Layer", UIControlState.Normal);
runningNet = neuralNetworkDeep;
}
deep = !deep;
}
示例13: PasswordTextField
public PasswordTextField()
{
var obfuscateButton = new UIButton (GetButtonRect());
obfuscateButton.SetTitle (ShowText, UIControlState.Normal);
obfuscateButton.SetTitleColor (UIColor.LightGray, UIControlState.Normal);
obfuscateButton.Font = buttonFont;
obfuscateButton.TouchUpInside += (sender, args) => {
SecureTextEntry = !SecureTextEntry;
Text = Text; //need this to address cursor position update issue
obfuscateButton.SetTitle (SecureTextEntry ? ShowText : HideText, UIControlState.Normal);
};
RightViewMode = UITextFieldViewMode.WhileEditing;
RightView = obfuscateButton;
}
示例14: BindClientButton
private void BindClientButton (UIButton v)
{
if (model.Client == null) {
v.Apply (Style.NewProject.NoClient);
v.SetTitle ("NewProjectClientHint".Tr (), UIControlState.Normal);
} else {
var text = model.Client.Name;
if (String.IsNullOrEmpty (text)) {
text = "NewProjectNoNameClient".Tr ();
}
v.Apply (Style.NewProject.WithClient);
v.SetTitle (text, UIControlState.Normal);
}
}
示例15: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
mapView.Delegate = new MyDelegate();
View = mapView;
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var secondViewModel = (SecondViewModel)ViewModel;
var hanAnnotation = new ZombieAnnotation(secondViewModel.Han);
mapView.AddAnnotation(hanAnnotation);
mapView.SetRegion(MKCoordinateRegion.FromDistance(
new CLLocationCoordinate2D(secondViewModel.Han.Location.Lat, secondViewModel.Han.Location.Lng),
20000,
20000), true);
var button = new UIButton(UIButtonType.RoundedRect);
button.Frame = new RectangleF(10, 10, 300, 40);
button.SetTitle("move", UIControlState.Normal);
Add(button);
var set = this.CreateBindingSet<SecondView, Core.ViewModels.SecondViewModel>();
set.Bind(hanAnnotation).For(a => a.Location).To(vm => vm.Han.Location);
set.Bind(button).For("Title").To(vm => vm.Han.Location);
set.Apply();
}