private UILabel CreateLabel(LinkString.Part part) { UILabel label = new UILabel(); label.Font = this.Font; label.HighlightedTextColor = this.TintColor; label.Text = part.Text; label.TextColor = this.TextColor; label.TranslatesAutoresizingMaskIntoConstraints = false; if (part.HasHandler) { UILongPressGestureRecognizer pressGesture = new UILongPressGestureRecognizer(gesture => this.OnPartPressed(gesture, part, label)); pressGesture.MinimumPressDuration = 0.001; label.AddGestureRecognizer(pressGesture); label.UserInteractionEnabled = true; this.SetUnderLineStyle(label, NSUnderlineStyle.Single); } label.SizeToFit(); return(label); }
private void OnPartPressed(UIGestureRecognizer gesture, LinkString.Part part, UILabel label) { if (gesture.State == UIGestureRecognizerState.Began) { label.Highlighted = true; this.SetUnderLineStyle(label, NSUnderlineStyle.None); } else if (gesture.State == UIGestureRecognizerState.Ended) { label.Highlighted = false; this.SetUnderLineStyle(label, NSUnderlineStyle.Single); this.LinkClicked(part); } }