Programatically added label does not expand
ptandel94 opened this issue · 1 comments
ptandel94 commented
When I add ExpandedLabel programatically as sub view then it does not detect proper touch coordinate.
label = ExpandableLabel(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: CGFloat.leastNormalMagnitude))
label?.collapsed = true
label?.shouldCollapse = true
label?.textReplacementType = .character
label?.setLessLinkWith(lessLink: "Show Less", attributes: [.foregroundColor:UIColor.red], position: .natural)
label?.collapsedAttributedLink = NSAttributedString(string: "Show More", attributes: [.font: UIFont.boldSystemFont(ofSize: (label?.font.pointSize)!)])
label?.numberOfLines = 1
view.addSubview(label!)
label?.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: label!, attribute: NSLayoutAttribute.leadingMargin, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.leadingMargin, multiplier: 1, constant: 0).isActive = true
NSLayoutConstraint(item: label!, attribute: NSLayoutAttribute.trailingMargin, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.trailingMargin, multiplier: 1, constant: 0).isActive = true
NSLayoutConstraint(item: label!, attribute: NSLayoutAttribute.topMargin, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.topMargin, multiplier: 1, constant: 0).isActive = true
NSLayoutConstraint(item: label!, attribute: NSLayoutAttribute.bottomMargin, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.bottomMargin, multiplier: 1, constant: 0).isActive = true
label?.text = "Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test "`
dawn360 commented
label?.isUserInteractionEnabled = true