本文整理汇总了C#中UIBarButtonItem.SetTitleTextAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# UIBarButtonItem.SetTitleTextAttributes方法的具体用法?C# UIBarButtonItem.SetTitleTextAttributes怎么用?C# UIBarButtonItem.SetTitleTextAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIBarButtonItem
的用法示例。
在下文中一共展示了UIBarButtonItem.SetTitleTextAttributes方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI setup from code
cancel.SetTitleTextAttributes (new UITextAttributes() { TextColor = UIColor.White }, UIControlState.Normal);
var label = new UILabel (new CGRect(0, 0, 80, 36)) {
Text = "Labor",
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (18),
};
labor = new UIBarButtonItem(label);
done = new UIBarButtonItem("Done", UIBarButtonItemStyle.Bordered, (sender, e) => {
laborViewModel
.SaveLaborAsync (assignmentViewModel.SelectedAssignment, laborViewModel.SelectedLabor)
.ContinueWith (_ => BeginInvokeOnMainThread (() => DismissViewController (true, null)));
});
done.SetTitleTextAttributes (new UITextAttributes() { TextColor = UIColor.White }, UIControlState.Normal);
done.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
space1 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
space2 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
tableView.Source =
tableSource = new TableSource();
}
示例2: NavLabelButton
public static void NavLabelButton (UIBarButtonItem v)
{
v.SetTitleTextAttributes (new UITextAttributes () {
Font = UIFont.FromName ("HelveticaNeue-Medium", 17f),
TextColor = Color.Green,
}, UIControlState.Normal);
}
示例3: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI that must be setup from code
View.BackgroundColor = Theme.BackgroundColor;
title = new UILabel (new RectangleF (0, 0, 100, 36)) {
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (16),
Text = "Items",
};
titleButton = new UIBarButtonItem (title);
toolbar.Items = new UIBarButtonItem[] { titleButton };
var textAttributes = new UITextAttributes { TextColor = UIColor.White };
edit = new UIBarButtonItem ("Edit", UIBarButtonItemStyle.Bordered, delegate {
edit.Title = tableView.Editing ? "Edit" : "Done";
tableView.SetEditing (!tableView.Editing, true);
});
edit.SetTitleTextAttributes (textAttributes, UIControlState.Normal);
edit.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
space = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
addItem = new UIBarButtonItem ("Add Item", UIBarButtonItemStyle.Bordered, OnAddItem);
addItem.SetTitleTextAttributes (textAttributes, UIControlState.Normal);
addItem.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
tableView.Source = new TableSource (this);
}
示例4: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI that has to be setup from code
View.BackgroundColor = Theme.BackgroundColor;
descriptionBackground.Image = Theme.RowEnd;
itemsBackground.Image =
hoursBackground.Image =
expensesBackground.Image = Theme.Inlay;
itemsLabel.TextColor =
items.TextColor =
hoursLabel.TextColor =
hours.TextColor =
expensesLabel.TextColor =
expenses.TextColor = UIColor.White;
description.TextColor =
descriptionTitle.TextColor = Theme.LabelColor;
//Setup our toolbar
var label = new UILabel (new RectangleF(0, 0, 100, 36)) {
Text = "Description",
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (16),
};
descriptionButton = new UIBarButtonItem(label);
viewHistory = new UIBarButtonItem("View History", UIBarButtonItemStyle.Bordered, (sender, e) => {
var menuViewModel = ServiceContainer.Resolve<MenuViewModel>();
menuViewModel.MenuIndex = SectionIndex.History;
});
viewHistory.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.White }, UIControlState.Normal);
viewHistory.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
}
示例5: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI setup from code
description.ShouldReturn = t => {
Save ();
return false;
};
cancel.SetTitleTextAttributes (new UITextAttributes () { TextColor = UIColor.White }, UIControlState.Normal);
cancel.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
var label = new UILabel (new RectangleF (0, 0, 80, 36)) {
Text = "Photo",
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (18),
};
var labor = new UIBarButtonItem (label);
var done = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Bordered, (sender, e) => Save ());
done.SetTitleTextAttributes (new UITextAttributes () { TextColor = UIColor.White }, UIControlState.Normal);
done.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
toolbar.Items = new UIBarButtonItem[] {
cancel,
new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace),
labor,
new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace),
done,
};
if (Theme.IsiOS7) {
photo.Frame = photoFrame.Frame;
date.Font = Theme.BoldFontOfSize (18);
time.Font =
deleteButton.Font = Theme.FontOfSize (18);
deleteButton.SetTitleColor (Theme.RedColor, UIControlState.Normal);
} else {
descriptionBackground.Image = Theme.ModalInlay;
photoFrame.Image = Theme.PhotoFrame;
deleteButton.SetBackgroundImage (Theme.DeleteButton, UIControlState.Normal);
deleteButton.SetTitleColor (UIColor.White, UIControlState.Normal);
}
}
示例6: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
cancel = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, (sender, e) => {
controller.Dismiss (true);
});
cancel.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.White }, UIControlState.Normal);
cancel.SetBackgroundImage (Theme.DarkBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
save = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, (sender, e) => {
//If blank, return
if (signatureView.IsBlank) {
new UIAlertView(string.Empty, "No signature!", null, "Ok").Show ();
return;
}
if (assignmentViewModel.Signature == null) {
assignmentViewModel.Signature = new Data.Signature { AssignmentId = assignmentViewModel.SelectedAssignment.Id };
}
assignmentViewModel.Signature.Image = signatureView.GetImage ().ToByteArray ();
assignmentViewModel.SaveSignatureAsync ()
.ContinueWith (_ => {
BeginInvokeOnMainThread (() => controller.Dismiss (true));
});
});
save.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.White }, UIControlState.Normal);
save.SetBackgroundImage (Theme.DarkBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
NavigationItem.LeftBarButtonItem = cancel;
NavigationItem.RightBarButtonItem = save;
NavigationController.NavigationBar.SetBackgroundImage (null, UIBarMetrics.Default);
signatureView = new SignaturePadView(View.Frame)
{
AutoresizingMask = UIViewAutoresizing.All,
};
View.AddSubview (signatureView);
}
示例7: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI to setup from code
title = new UILabel (new RectangleF (0, 0, 160, 36)) {
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (16),
Text = "Expenses",
};
titleButton = new UIBarButtonItem (title);
toolbar.Items = new UIBarButtonItem[] { titleButton };
var textAttributes = new UITextAttributes { TextColor = UIColor.White };
edit = new UIBarButtonItem ("Edit", UIBarButtonItemStyle.Bordered, delegate {
edit.Title = tableView.Editing ? "Edit" : "Done";
tableView.SetEditing (!tableView.Editing, true);
});
edit.SetTitleTextAttributes (textAttributes, UIControlState.Normal);
edit.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
space = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
addItem = Theme.IsiOS7 ?
new UIBarButtonItem(UIBarButtonSystemItem.Add, OnAddExpense) :
new UIBarButtonItem ("Add Expense", UIBarButtonItemStyle.Bordered, OnAddExpense);
addItem.SetTitleTextAttributes (textAttributes, UIControlState.Normal);
addItem.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
tableView.Source = new TableSource (this);
if (Theme.IsiOS7) {
tableView.SeparatorStyle = UITableViewCellSeparatorStyle.SingleLine;
addItem.TintColor = UIColor.White;
} else {
View.BackgroundColor = Theme.BackgroundColor;
}
}
示例8: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI setup from code
cancel.SetTitleTextAttributes (new UITextAttributes() { TextColor = UIColor.White }, UIControlState.Normal);
var label = new UILabel (new RectangleF(0, 0, 80, 36)) {
Text = "Expense",
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (18),
};
expense = new UIBarButtonItem(label);
done = new UIBarButtonItem("Done", UIBarButtonItemStyle.Bordered, (sender, e) => {
//Save the expense
var task = expenseViewModel.SaveExpenseAsync (assignmentViewModel.SelectedAssignment, expenseViewModel.SelectedExpense);
//Save the photo if we need to
if (expenseViewModel.Photo != null) {
task = task
.ContinueWith (_ => expenseViewModel.Photo.ExpenseId = expenseViewModel.SelectedExpense.Id)
.ContinueWith (expenseViewModel.SavePhotoAsync ());
}
//Dismiss the controller after the other tasks
task.ContinueWith (_ => BeginInvokeOnMainThread(() => DismissViewController (true, null)));
});
done.SetTitleTextAttributes (new UITextAttributes() { TextColor = UIColor.White }, UIControlState.Normal);
done.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
space1 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
space2 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
tableView.Source =
tableSource = new TableSource();
}
示例9: CreateTitleButtonItem
private UIBarButtonItem CreateTitleButtonItem ()
{
var title = new UIBarButtonItem (ToolbarTitle,
UIBarButtonItemStyle.Plain,
null, null);
var attributes = ToolbarTitleTextAttributes;
title.SetTitleTextAttributes (attributes, UIControlState.Normal);
title.SetTitleTextAttributes (attributes, UIControlState.Disabled);
title.Enabled = false;
return title;
}
示例10: Apply
public static void Apply (UIBarButtonItem.UIBarButtonItemAppearance appearance, string options = null)
{
if (IsModern)
return;
var font = UIFont.FromName (BarButtonFontName, BarButtonFontSize);
appearance.SetBackgroundImage (
ButtonImage.Value,
UIControlState.Normal,
UIBarMetrics.Default);
appearance.SetBackButtonBackgroundImage (
BackButtonImage.Value,
UIControlState.Normal,
UIBarMetrics.Default);
appearance.SetTitlePositionAdjustment (new UIOffset (0, 1), UIBarMetrics.Default);
appearance.SetTitleTextAttributes (new UITextAttributes {
TextColor = BarTextColor,
TextShadowColor = BarButtonTextShadowColor,
TextShadowOffset = BarButtonTextShadowOffset,
Font = font,
}, UIControlState.Normal);
appearance.SetTitleTextAttributes (new UITextAttributes {
TextColor = UIColor.FromWhiteAlpha (0.9f, 1),
TextShadowColor = BarButtonTextShadowColor,
TextShadowOffset = BarButtonTextShadowOffset,
Font = font,
}, UIControlState.Disabled);
appearance.SetTitleTextAttributes (new UITextAttributes {
TextColor = UIColor.White,
TextShadowColor = BarButtonTextShadowColor,
TextShadowOffset = BarButtonTextShadowOffset,
Font = font,
}, UIControlState.Highlighted);
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//UI that has to be setup from code
View.BackgroundColor = Theme.BackgroundColor;
description.TextColor =
descriptionTitle.TextColor = Theme.LabelColor;
//Setup our toolbar
var label = new UILabel (new CGRect(0, 0, 100, 36)) {
Text = "Description",
TextColor = UIColor.White,
BackgroundColor = UIColor.Clear,
Font = Theme.BoldFontOfSize (16),
};
descriptionButton = new UIBarButtonItem(label);
viewHistory = new UIBarButtonItem("View History", UIBarButtonItemStyle.Bordered, (sender, e) => {
var menuViewModel = ServiceContainer.Resolve<MenuViewModel>();
menuViewModel.MenuIndex = SectionIndex.History;
});
viewHistory.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.White }, UIControlState.Normal);
viewHistory.SetBackgroundImage (Theme.BlueBarButtonItem, UIControlState.Normal, UIBarMetrics.Default);
if (Theme.IsiOS7) {
descriptionBackground.BackgroundColor = UIColor.White;
itemsLabel.Font =
items.Font =
hoursLabel.Font =
hours.Font =
expensesLabel.Font =
expenses.Font = Theme.FontOfSize (18);
itemsLabel.TextColor =
items.TextColor =
hoursLabel.TextColor =
hours.TextColor =
expensesLabel.TextColor =
expenses.TextColor = Theme.LabelColor;
itemsBackground.BackgroundColor =
hoursBackground.BackgroundColor =
expensesBackground.BackgroundColor = Theme.LightGrayColor;
//Move backgrounds around to appear as lines
var frame = itemsBackground.Frame;
frame.X = 0;
frame.Y += frame.Height - 1;
frame.Height = 1;
frame.Width = View.Frame.Width;
itemsBackground.Frame = frame;
frame = hoursBackground.Frame;
frame.X = 0;
frame.Y += frame.Height - 1;
frame.Height = 1;
frame.Width = View.Frame.Width;
hoursBackground.Frame = frame;
frame = expensesBackground.Frame;
frame.X = 0;
frame.Y += frame.Height - 1;
frame.Height = 1;
frame.Width = View.Frame.Width;
expensesBackground.Frame = frame;
} else {
descriptionBackground.Image = Theme.RowEnd;
itemsBackground.Image =
hoursBackground.Image =
expensesBackground.Image = Theme.Inlay;
itemsLabel.TextColor =
items.TextColor =
hoursLabel.TextColor =
hours.TextColor =
expensesLabel.TextColor =
expenses.TextColor = UIColor.White;
}
}
示例12: SetBarButtonItemAppearance
public static void SetBarButtonItemAppearance(UIBarButtonItem.UIBarButtonItemAppearance appearance, UIColor color, UIColor highlightedColor, UIColor textColor, float cornerRadius, float borderWidth)
{
UIImage backButtonPortraitImage = FlatUI.BackButtonImage(color,
UIBarMetrics.Default,
cornerRadius,
color.Darken(2),
borderWidth);
UIImage highlightedBackButtonPortraitImage = FlatUI.BackButtonImage(highlightedColor,
UIBarMetrics.Default,
cornerRadius,
highlightedColor.Darken(2),
borderWidth);
UIImage backButtonLandscapeImage = FlatUI.BackButtonImage(color,
UIBarMetrics.LandscapePhone,
cornerRadius,
color.Darken(2),
borderWidth);
UIImage highlightedBackButtonLandscapeImage = FlatUI.BackButtonImage(highlightedColor,
UIBarMetrics.LandscapePhone,
cornerRadius,
highlightedColor.Darken(2),
borderWidth);
appearance.SetBackButtonBackgroundImage(backButtonPortraitImage, UIControlState.Normal, UIBarMetrics.Default);
appearance.SetBackButtonBackgroundImage(backButtonLandscapeImage, UIControlState.Normal, UIBarMetrics.LandscapePhone);
appearance.SetBackButtonBackgroundImage(highlightedBackButtonPortraitImage, UIControlState.Highlighted, UIBarMetrics.Default);
appearance.SetBackButtonBackgroundImage(highlightedBackButtonLandscapeImage, UIControlState.Highlighted, UIBarMetrics.LandscapePhone);
appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(1f, 1f), UIBarMetrics.Default);
appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(1f, 1f), UIBarMetrics.LandscapePhone);
UIImage buttonImageNormal = FlatUI.Image(color, cornerRadius, color.Darken(2), borderWidth);
UIImage buttonImageHighlighted = FlatUI.Image(highlightedColor, cornerRadius, highlightedColor.Darken(2), borderWidth);
appearance.SetBackgroundImage(buttonImageNormal, UIControlState.Normal, UIBarMetrics.Default);
appearance.SetBackgroundImage(buttonImageHighlighted, UIControlState.Highlighted, UIBarMetrics.Default);
UITextAttributes titleTextAttributes = appearance.GetTitleTextAttributes(UIControlState.Normal);
if (titleTextAttributes == null)
titleTextAttributes = new UITextAttributes();
titleTextAttributes.TextShadowColor = UIColor.Clear;
titleTextAttributes.TextShadowOffset = new UIOffset(0, 0);
titleTextAttributes.TextColor = textColor;
titleTextAttributes.Font = FlatUI.FontOfSize(0);
appearance.SetTitleTextAttributes(titleTextAttributes, UIControlState.Normal);
appearance.SetTitleTextAttributes(titleTextAttributes, UIControlState.Highlighted);
}