So far this is my attempt at achieving this.
if searchBar.text == ""
{
searchBar.addSubview(placeholder)
searchBar.addConstraintsWithFormat("V:|[v0]|", views: placeholder)
phconstraint = NSLayoutConstraint(item: placeholder, attribute: .centerX, relatedBy: .equal, toItem: searchBar, attribute: .centerX, multiplier: 1, constant: 0)
}
else
{
placeholder.removeFromSuperview()
}
The above code best explains the logic behind what I want to achieve. Is there some method in UITextField to detect the addition of text or maybe some notification?
Any suggestions?