Skip to content

Commit

Permalink
added minimumLineHeight and applied ceil on height
Browse files Browse the repository at this point in the history
added minimumLineHeight to be able to handle emojis properly and applied ceil on intrinsicContentSize() to avoid glitches created by decimal pixels
  • Loading branch information
demonar authored Jul 21, 2016
1 parent fa897a0 commit a741ac8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ActiveLabel/ActiveLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public protocol ActiveLabelDelegate: class {
@IBInspectable public var lineSpacing: Float = 0 {
didSet { updateTextStorage(parseText: false) }
}

@IBInspectable public var minimumLineHeight: Float = 0 {
didSet { updateTextStorage(parseText: false) }
}
// MARK: - public methods
public func handleMentionTap(handler: (String) -> ()) {
mentionTapHandler = handler
Expand Down Expand Up @@ -135,7 +137,7 @@ public protocol ActiveLabelDelegate: class {
let superSize = super.intrinsicContentSize()
textContainer.size = CGSize(width: superSize.width, height: CGFloat.max)
let size = layoutManager.usedRectForTextContainer(textContainer)
return CGSize(width: ceil(size.width), height: ceil(size.height))
return CGSize(width: size.width, height: ceil(size.height))
}

// MARK: - touch events
Expand Down Expand Up @@ -306,7 +308,7 @@ public protocol ActiveLabelDelegate: class {
paragraphStyle.lineBreakMode = NSLineBreakMode.ByWordWrapping
paragraphStyle.alignment = textAlignment
paragraphStyle.lineSpacing = CGFloat(lineSpacing)

paragraphStyle.minimumLineHeight = CGFloat(minimumLineHeight > 0 ? minimumLineHeight: self.font.pointSize * 1.14)
attributes[NSParagraphStyleAttributeName] = paragraphStyle
mutAttrString.setAttributes(attributes, range: range)

Expand Down

0 comments on commit a741ac8

Please sign in to comment.