private void Initialize() { titleLabel = new UILabel(); titleLabel.TranslatesAutoresizingMaskIntoConstraints = false; titleLabel.TextAlignment = UITextAlignment.Center; titleLabel.Font = UIFont.SystemFontOfSize(23f); AddSubview(titleLabel); titleLabel.CenterXAnchor.ConstraintEqualTo(CenterXAnchor).Active = true; titleLabel.CenterYAnchor.ConstraintEqualTo(CenterYAnchor, -1).Active = true; titleLabel.WidthAnchor.ConstraintEqualTo(WidthAnchor, -20).Active = true; titleLabel.SetContentHuggingPriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Vertical); titleLabel.Lines = 1; titleLabel.LineBreakMode = UILineBreakMode.TailTruncation; var topSeparator = new SeparatorView(); topSeparator.TranslatesAutoresizingMaskIntoConstraints = false; topSeparator.BackgroundColor = ColorPallete.Gray; AddSubview(topSeparator); topSeparator.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true; topSeparator.TrailingAnchor.ConstraintEqualTo(TrailingAnchor).Active = true; topSeparator.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true; var bottomSeparator = new SeparatorView(); bottomSeparator.TranslatesAutoresizingMaskIntoConstraints = false; bottomSeparator.BackgroundColor = ColorPallete.Gray; AddSubview(bottomSeparator); bottomSeparator.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true; bottomSeparator.TrailingAnchor.ConstraintEqualTo(TrailingAnchor).Active = true; bottomSeparator.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true; }
private void Initialize(CGRect frame) { containerView = new UIView { BackgroundColor = UIColor.White }; separatorView = new SeparatorView { BackgroundColor = ColorPallete.Gray }; containerView.Add(separatorView); iconImageView = new UIImageView { ContentMode = UIViewContentMode.ScaleAspectFit }; containerView.Add(iconImageView); textLabel = new UILabel { Lines = 1, LineBreakMode = UILineBreakMode.MiddleTruncation, Font = UIFont.SystemFontOfSize(17) }; containerView.Add(textLabel); subtitleTextLabel = new UILabel { Lines = 1, LineBreakMode = UILineBreakMode.MiddleTruncation, Font = UIFont.SystemFontOfSize(12), TextColor = UIColor.Gray }; containerView.Add(subtitleTextLabel); accessoryImageView = new UIImageView { ContentMode = UIViewContentMode.Center }; containerView.Add(accessoryImageView); checkmarkButton = new CheckmarkButton(new CGRect()); BackgroundColor = UIColor.White; accessoryImageViewTapRecognizer = new UITapGestureRecognizer(HandleAccessoryImageTap); accessoryImageViewTapRecognizer.Delegate = this; accessoryImageView.AddGestureRecognizer(accessoryImageViewTapRecognizer); accessoryImageView.UserInteractionEnabled = true; Add(checkmarkButton); Add(containerView); containerView.TranslatesAutoresizingMaskIntoConstraints = false; separatorView.TranslatesAutoresizingMaskIntoConstraints = false; textLabel.TranslatesAutoresizingMaskIntoConstraints = false; subtitleTextLabel.TranslatesAutoresizingMaskIntoConstraints = false; iconImageView.TranslatesAutoresizingMaskIntoConstraints = false; checkmarkButton.TranslatesAutoresizingMaskIntoConstraints = false; accessoryImageView.TranslatesAutoresizingMaskIntoConstraints = false; SetupContainerViewConstraint(); SetupSeparatorViewConstraints(); SetupIconImageViewConstraints(); SetupAccessoryImageViewConstraints(); SetupTitleLabelConstraints(); SetupSubtitleLabelConstraints(); SetupCheckmarkButtonConstraints(); }