本文整理汇总了C#中UITextField.SetContentHuggingPriority方法的典型用法代码示例。如果您正苦于以下问题:C# UITextField.SetContentHuggingPriority方法的具体用法?C# UITextField.SetContentHuggingPriority怎么用?C# UITextField.SetContentHuggingPriority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITextField
的用法示例。
在下文中一共展示了UITextField.SetContentHuggingPriority方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.BackgroundColor = UIColor.Blue;
TheViewController = this;
//Enumerate SVG with BundleResource action in the Resources/svg folder
//var path = Path.Combine(NSBundle.MainBundle.BundlePath,"svg");
var bundleSvgs = new List<string>(); //Directory.EnumerateFiles(path, "*.svg").Select(Path.GetFileName).OrderBy(s => s).ToList();
//Enumerate SVG with EmbeddedResource action in the XamSvgDemo.Shared project, in the images folder.
var assembly = typeof (App).GetTypeInfo().Assembly;
var sharedSvgs = assembly.GetManifestResourceNames().Where(n => n.EndsWith(".svg")).OrderBy(n => n).ToArray();
//Combine both lists
var svgNames = bundleSvgs.Select(s => "svg/" + s).Concat(
sharedSvgs.Select(s => "res:" + s)
).ToList();
var index = 0;
#if !USEAUTOLAYOUT
//Fix width, let height be changed by UISvgImageView
var bounds = UIScreen.MainScreen.Bounds;
image = new UISvgImageView(svgNames[index], bounds.Width, 0) { Frame = new CGRect(0,0,bounds.Width, bounds.Height) };
#else
image = new UISvgImageView(svgNames[index]);
#endif
image.Layer.BorderWidth = 1;
image.Layer.BorderColor = UIColor.Green.CGColor;
View.Add(image);
title = new UILabel
{
TextColor=UIColor.White,
Font = UIFont.SystemFontOfSize(14f),
LineBreakMode = UILineBreakMode.CharacterWrap,
Lines = 0,
#if !USEAUTOLAYOUT
Frame = new CGRect(0,30,320,100),
#endif
};
View.Add(title);
#if USEAUTOLAYOUT
var back = new UIView {BackgroundColor = UIColor.DarkGray.ColorWithAlpha(.6f)};
var back2 = new UIView { BackgroundColor = UIColor.Clear };
var inputUrl = new UITextField
{
TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(14f),
AttributedPlaceholder = new NSMutableAttributedString("Enter url of svg file, or tap anywhere for demo",
foregroundColor: UIColor.Gray, font: UIFont.ItalicSystemFontOfSize(12)),
KeyboardType = UIKeyboardType.Url, AutocorrectionType = UITextAutocorrectionType.No,
AutocapitalizationType = UITextAutocapitalizationType.None,
//ReturnKeyType = UIReturnKeyType.Go,
//EnablesReturnKeyAutomatically = true, ShouldReturn =
};
//var inputOk = new UISvgImageView("res:images.download", 25, colorMapping: "000000=FF546D", colorMappingSelected: "000000=00FF59")
//{
// UserInteractionEnabled = true,
//};
var inputOk = new UISvgImageView
{
UserInteractionEnabled = true,
TranslatesAutoresizingMaskIntoConstraints = false,
FillWidth = 25,
ColorMapping="000000=FF546D",
ColorMappingSelected="000000=00FF59",
BundleName = "res:images.download"
};
//var inputOk = new UISvgImageView("", 25); //for debug
View.Add(back);
View.Add(back2);
View.SendSubviewToBack(back);
View.SendSubviewToBack(image); //image behind back
View.Add(inputUrl);
View.Add(inputOk);
inputOk.AddGestureRecognizer(new UITapGestureRecognizer(tap =>
{
inputUrl.ResignFirstResponder();
var dontWait = LoadSvg(inputUrl.Text);
}));
inputUrl.EditingDidBegin += (sender, args) =>
{
inputUrl.SelectAll(this);
};
inputUrl.SetContentHuggingPriority((float)UILayoutPriority.FittingSizeLevel, UILayoutConstraintAxis.Horizontal);
inputOk.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Horizontal);
View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
View.AddConstraints(
back.WithSameTop(inputOk).Minus(5),
back.AtLeftOf(View),
back.AtRightOf(View),
back.WithSameBottom(title).Plus(5),
//.........这里部分代码省略.........