ParagraphView.swift 662 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // ParagraphView.swift
  3. // ResetTransmitter
  4. //
  5. // Copyright © 2018 LoopKit Authors. All rights reserved.
  6. //
  7. import UIKit
  8. class ParagraphView: UITextView {
  9. override func awakeFromNib() {
  10. super.awakeFromNib()
  11. textContainer.lineFragmentPadding = 0
  12. let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
  13. paragraphStyle.paragraphSpacing = 10
  14. attributedText = NSAttributedString(
  15. string: text,
  16. attributes: [
  17. .paragraphStyle: paragraphStyle,
  18. .font: UIFont.preferredFont(forTextStyle: .body)
  19. ]
  20. )
  21. }
  22. }