本文整理汇总了C#中UIImageView.SetImage方法的典型用法代码示例。如果您正苦于以下问题:C# UIImageView.SetImage方法的具体用法?C# UIImageView.SetImage怎么用?C# UIImageView.SetImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIImageView
的用法示例。
在下文中一共展示了UIImageView.SetImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
View.BackgroundColor = UIColor.White;
ImageView = new UIImageView (View.Bounds) {
ContentMode = UIViewContentMode.ScaleAspectFit
};
View.AddSubview (ImageView);
if (ImageUrl != null) {
ImageView.SetImage (ImageUrl, null, SDWebImageOptions.ProgressiveDownload, ProgressHandler, CompletedHandler);
}
}
示例2: ViewDidLoad
public async override void ViewDidLoad()
{
try {
this.InitLeftButton();
LongRunning = true;
Title = "Site Info";
base.ViewDidLoad();
var site = await ServiceProxy.GetSiteInfo(_siteName);
var statistics = site.items[0];
var imageView = new UIImageView(new RectangleF(0, 0, View.Frame.Width, 60));
imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
imageView.SetImage(new MonoTouch.Foundation.NSUrl(statistics.site.logo_url));
AddTableHeader(imageView);
AddRow(new SubtitleDynamicRow {
Text = statistics.site.NameDecoded,
Details = statistics.site.AudienceDecoded
});
AddSubtitleFixedRow("Site Url", statistics.site.site_url);
AddValue1FixedRow("Launch Date", BclEx.UnixToDate(statistics.site.launch_date).ToString("d MMM yyyy"));
AddRow(new DefaultFixedRow {
Accessory = UITableViewCellAccessory.DisclosureIndicator,
Text = "View Moderators",
NavController = () => new ModeratorsController()
});
AddHeaderRow("Site statistics");
AddValue1FixedRow("Total Questions", statistics.total_questions.ToString());
AddValue1FixedRow("Unanswered Questions", statistics.total_unanswered.ToString());
AddValue1FixedRow("Total Answers", statistics.total_answers.ToString());
AddValue1FixedRow("Accepted Answers", statistics.total_accepted.ToString());
AddValue1FixedRow("Total Comments", statistics.total_comments.ToString());
AddValue1FixedRow("Total Users", statistics.total_users.ToString());
AddValue1FixedRow("New Active Users", statistics.new_active_users.ToString());
AddValue1FixedRow("Total Votes", statistics.total_votes.ToString());
AddValue1FixedRow("Total Badges", statistics.total_badges.ToString());
AddValue1FixedRow("Badges per minute", statistics.badges_per_minute.ToString());
AddValue1FixedRow("Questions per minute", statistics.questions_per_minute.ToString());
AddValue1FixedRow("Answers per minute", statistics.answers_per_minute.ToString());
AddHeaderRow("Developer info");
AddValue1FixedRow("API Revision", statistics.api_revision);
AddValue1FixedRow("API Site Param", statistics.site.api_site_parameter);
AddSubtitleFixedRow("Markdown Extensions", statistics.site.markdown_extensions.JoinStrings(", "));
if (statistics.site.aliases != null && statistics.site.aliases.Any())
AddSubtitleDynamicRow("Aliases", statistics.site.aliases.JoinStrings(", "));
AddValue1FixedRow("Site State", statistics.site.site_state);
AddValue1FixedRow("Site Type", statistics.site.site_type);
ForceReloadData();
}
catch (Exception ex) {
this.UnhandledError(ex);
}
}
示例3: OnRequestHeaderImages
private void OnRequestHeaderImages (List<string> images)
{
var defaultImage = UIImage.FromFile (ViewModel.DefaultAccountImageName);
AccountImageView.Hidden = images.Count == 0;
// clear all existing entries before beginning
foreach (UIView view in AccountsView.Subviews) {
if(!view.Equals(AccountImageView)) {
AccountsView.RemoveConstraints (view.Constraints);
view.RemoveFromSuperview ();
}
}
if(images.Count > 0)
{
// proceed and add the new ones
var prevImageView = AccountImageView;
var prevTrailingConstraint = AccountImageViewTrailingConstraint;
var rect = CGRect.FromLTRB (prevImageView.Frame.X + 2, prevImageView.Frame.Y + 2, prevImageView.Frame.Width - 4, prevImageView.Frame.Height - 4);
var path = UIBezierPath.FromRoundedRect (rect, prevImageView.Frame.Height / 2);
var prevMaskLayer = new CAShapeLayer ();
if(!AccountsView.Constraints.Contains(AccountImageViewTrailingConstraint))
{
AccountsView.AddConstraint (AccountImageViewTrailingConstraint);
}
prevMaskLayer.Path = path.CGPath;
prevMaskLayer.ShadowColor = UIColor.Black.CGColor;
prevMaskLayer.ShadowOpacity = 0.35f;
prevMaskLayer.ShadowOffset = new CGSize (0, 1);
prevMaskLayer.ShadowRadius = 2;
prevMaskLayer.ShadowPath = path.CGPath;
prevImageView.ClipsToBounds = false;
prevImageView.Layer.Mask = prevMaskLayer;
prevImageView.Layer.MasksToBounds = false;
prevImageView.SetImage (new NSUrl(images [0]), defaultImage);
images.RemoveAt (0);
AccountsView.Layer.MasksToBounds = false;
AccountsView.ClipsToBounds = false;
foreach (string imageUrl in images)
{
var imageView = new UIImageView ();
var maskLayer = new CAShapeLayer ();
maskLayer.Path = path.CGPath;
maskLayer.ShadowColor = prevMaskLayer.ShadowColor;
maskLayer.ShadowOpacity = prevMaskLayer.ShadowOpacity;
maskLayer.ShadowOffset = prevMaskLayer.ShadowOffset;
maskLayer.ShadowRadius = prevMaskLayer.ShadowRadius;
maskLayer.ShadowPath = prevMaskLayer.ShadowPath;
imageView.ClipsToBounds = prevImageView.ClipsToBounds;
imageView.Layer.Mask = maskLayer;
imageView.Layer.MasksToBounds = prevImageView.Layer.MasksToBounds;
imageView.TranslatesAutoresizingMaskIntoConstraints = false;
imageView.SetImage (new NSUrl (imageUrl), defaultImage);
var heightConstraint = NSLayoutConstraint.Create (imageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, prevImageView.Frame.Height);
var widthConstraint = NSLayoutConstraint.Create (imageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, prevImageView.Frame.Width);
var leadingConstraint = NSLayoutConstraint.Create (imageView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, prevImageView, NSLayoutAttribute.Trailing, 1, -prevImageView.Frame.Width/2);
var centerYConstraint = NSLayoutConstraint.Create (imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, AccountsView, NSLayoutAttribute.CenterY, 1, 0);
var trailingConstraint = NSLayoutConstraint.Create (imageView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, AccountsView, NSLayoutAttribute.Trailing, 1, 0);
AccountsView.AddSubview (imageView);
AccountsView.SendSubviewToBack (imageView);
AccountsView.RemoveConstraint (prevTrailingConstraint);
AccountsView.AddConstraint (heightConstraint);
AccountsView.AddConstraint (widthConstraint);
AccountsView.AddConstraint (leadingConstraint);
AccountsView.AddConstraint (centerYConstraint);
AccountsView.AddConstraint (trailingConstraint);
prevMaskLayer = maskLayer;
prevImageView = imageView;
prevTrailingConstraint = trailingConstraint;
}
AccountsView.LayoutIfNeeded ();
}
}
示例4: MakeImageFromURL
public static void MakeImageFromURL(UIImageView imageHolder, string url)
{
// using SDWebImage to lazy load and
// cache the images
imageHolder.SetImage (new NSUrl (url));
}