Skip to content

vialyx/placeholderTextView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlaceholderTextView

The simple way to work with attributed placeholder in you UITextView.

  1. Use PlaceholderTextView class instead of UITextView;
  2. Customize Icon & attributed placeholder
@IBOutlet weak var tvMessage: PlaceholderTextView!

  let icon: NSTextAttachment = NSTextAttachment()
  icon.image = UIImage(named: "paper-plane")
  let iconString = NSMutableAttributedString(attributedString: NSAttributedString(attachment: icon))
  
  tvMessage.icon = icon

  let textColor = UIColor.gray
  let lightFont = UIFont(name: "Helvetica-Light", size: tvMessage.font!.pointSize)
  let italicFont = UIFont(name: "Helvetica-LightOblique", size: tvMessage.font!.pointSize)
  let message = NSAttributedString(string: " " + "Personal Message", attributes: [ NSFontAttributeName: lightFont!,   NSForegroundColorAttributeName: textColor])
  iconString.append(message)
  let option = NSAttributedString(string: " " + "Optional", attributes: [ NSFontAttributeName: italicFont!, NSForegroundColorAttributeName: textColor])
  iconString.append(option)
  
  tvMessage.attributedPlaceHolder = iconString
  
  tvMessage.layoutSubviews()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages