public override void ViewDidLoad () { base.ViewDidLoad (); float textWidth; float titleHeight; float dateHeight; float descriptionHeight; float centerX; float y; this.View.Frame = new RectangleF (0, 0, 320, 420); this.View.BackgroundColor = Resources.Colors.Background; string imagePath = History.ImageUrl; textWidth = this.View.Bounds.Width - 2 * TextLeftStart; centerX = this.View.Center.X; var lblTitle = new UILabel (); lblTitle.Lines = 0; lblTitle.TextColor = UIColor.FromRGB (218, 188, 0); lblTitle.Font = titleFont; lblTitle.Text = History.Title; titleHeight = lblTitle.GetHeight4Text (textWidth); y = YStart; lblTitle.Frame = new RectangleF (TextLeftStart, y, textWidth, titleHeight); lblTitle.TextAlignment = UITextAlignment.Center; var lblDate = new UILabel (); lblDate.Lines = 0; lblDate.TextColor = UIColor.White; lblDate.Font = dateFont; lblDate.Text = History.Date; dateHeight = lblDate.GetHeight4Text (textWidth); y += TextYOffset + titleHeight; lblDate.Frame = new RectangleF (TextLeftStart, y, textWidth, dateHeight); lblDate.TextAlignment = UITextAlignment.Center; var lblDescription = new UILabel (); lblDescription.Lines = 0; lblDescription.TextColor = UIColor.White; lblDescription.Font = descrFont; lblDescription.Text = History.Description; descriptionHeight = lblDescription.GetHeight4Text (textWidth); var imageView = new UIImageView (); y += 2 * TextYOffset + dateHeight; float maxImageHeight = this.View.Bounds.Height - descriptionHeight - y - 40; var img = UIImage.FromFile (imagePath); var resizer = new ImageResizer (img); resizer.RatioResize (MaxPicWidht, maxImageHeight); var modImage = resizer.ModifiedImage; var imgX = centerX - modImage.Size.Width / 2; imageView.Frame = new RectangleF (imgX, y, modImage.Size.Width, modImage.Size.Height); //imageView.Image = modImage; imageView.Image = img; y += 2 * TextYOffset + imageView.Bounds.Height; lblDescription.Frame = new RectangleF (TextLeftStart, y, textWidth, descriptionHeight); lblDescription.TextAlignment = UITextAlignment.Center; this.View.AddSubview (imageView); this.View.AddSubview (lblTitle); this.View.AddSubview (lblDate); this.View.AddSubview (lblDescription); this.View.SetLabelsBGColor (UIColor.Clear); }
private UIView GetSectionView (string text, bool isHeader) { if (string.IsNullOrEmpty (text)) return null; float viewHeight = 0f; float labelHeight = 0f; UIView view = new UIView (); UILabel label = new UILabel (); if (isHeader) { label.Font = fontHeader; label.TextAlignment = UITextAlignment.Left; label.ShadowColor = UIColor.Black; label.ShadowOffset = new SizeF (0, 1f); viewHeight = HEADER_PADDING; } else { label.Font = fontFooter; label.TextAlignment = UITextAlignment.Center; label.AutoresizingMask = UIViewAutoresizing.FlexibleMargins; } label.Text = text; labelHeight = label.GetHeight4Text (300); viewHeight += labelHeight; view.Frame = new RectangleF (0f, 0f, 300f, viewHeight); view.AutoresizingMask = UIViewAutoresizing.FlexibleMargins; label.Frame = isHeader ? new RectangleF (12f, viewHeight - labelHeight - 5, 300f, labelHeight) : new RectangleF (10f, 0, 300f, labelHeight); label.Lines = 0; label.BackgroundColor = UIColor.Clear; label.Opaque = false; label.TextColor = UIColor.White; view.AddSubview (label); return view; }
private UIView GetHeaderView () { float paddingLeft = 10f; float paddingBottom = 10f; float textHeight = 0; float y = 3; float textWidth = this.Frame.Width - paddingLeft * 2; var lblCounter = new UILabel (){ TextColor = Resources.Colors.Background, Font = pointFont, BackgroundColor = UIColor.Clear, Text = Locale.Format ("Frage {0} von {1}", CurrentQuestionNumber, TotalQuestionCount), }; textHeight = lblCounter.GetHeight4Text (textWidth); lblCounter.Frame = new RectangleF (paddingLeft, y, textWidth, textHeight); y += textHeight; var lblPunkten = new UILabel (){ TextColor = Resources.Colors.Background, BackgroundColor = UIColor.Clear, Font = pointFont, Text = Locale.Format ("{0} von {1} Punkten erreicht", CurrentPoints, TotalPoints) }; textHeight = lblPunkten.GetHeight4Text (textWidth); lblPunkten.Frame = new RectangleF (paddingLeft, y, textWidth, textHeight); y += textHeight; var topView = new UIView (); topView.BackgroundColor = UIColor.FromRGB (219, 219, 219); topView.Frame = new RectangleF (0, 0, this.Frame.Width, y + 5); y += 5; /* var lblFrage = new UILabel (){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth, TextColor = Resources.Colors.Button, BackgroundColor = UIColor.Clear, Font = quizFont, Text = CurrentQuestion.Text, LineBreakMode = UILineBreakMode.WordWrap, Lines = 0, }; textHeight = lblFrage.GetHeight4Text (textWidth); lblFrage.Frame = new RectangleF (paddingLeft, y, textWidth, textHeight); */ var txtFrage = new UITextView (){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth, TextColor = Resources.Colors.Button, BackgroundColor = UIColor.Clear, Font = Util.IsPhone5() ? UIFont.BoldSystemFontOfSize (quizSize) : UIFont.BoldSystemFontOfSize (quizSize - 2), Text = CurrentQuestion.Text, UserInteractionEnabled = true, Editable= false, ShowsVerticalScrollIndicator = false, ScrollsToTop = true }; textHeight = Util.IsPhone5() ? 150 : 95; txtFrage.Frame = new RectangleF (paddingLeft-5, y, textWidth + 5, textHeight); y += textHeight; var view = new UIView (){ //AutoresizingMask = UIViewAutoresizing.FlexibleDimensions | UIViewAutoresizing.FlexibleMargins, BackgroundColor = UIColor.Clear, Frame = new RectangleF (0, 0, this.Frame.Width, y), }; topView.AddSubview (lblCounter); topView.AddSubview (lblPunkten); view.AddSubview (topView); view.AddSubview (txtFrage); //view.AddSubview (lblFrage); return view; }