I am a IOS learner. I was doing a sample project, in which i require "More" and "Less" text indicators in a UILabel
for which i have added a SingleTapGestureRecognizer
to expand and contract based on the text content.The text content comes from API and is dynamic.
Here i have attached the screen shot of my required output.(The screen shots are from android).
Also i resize the UILabel programmatically except the constraints(No Auto layout). the code use for tap gesture is
In viewDidLoad()
let singleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: "singleTapped")
singleTapGestureRecognizer.numberOfTapsRequired = 1
singleTapGestureRecognizer.enabled = true
singleTapGestureRecognizer.cancelsTouchesInView = false
lblAmneties.addGestureRecognizer(singleTapGestureRecognizer)
the method is
var amnetiesClicked = false
func singleTapped()
{
if(amnetiesClicked == false) { amnetiesClicked = true }
else { amnetiesClicked = false }
if(amnetiesClicked == true)
{
Amneties.sizeToFit()
self.display()
}
else
{
if(self.Amneties.frame.size.height > 70 )
{
self.Amneties.frame.size.height = 70
self.display()
}
}
}
Here display()
is the method where i align all the contents of the view programmatically.
I have no idea on how to do it. I use xcode 7.1.1 Swift 2.0