fixed small error in refactor.
This commit is contained in:
parent
73ac4b932b
commit
6d52663b4f
@ -510,7 +510,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
Provides a text container and layout manager of how the text would appear on screen.
|
Provides a text container and layout manager of how the text would appear on screen.
|
||||||
They are used in tandem to derive low-level TextKit results of the label.
|
They are used in tandem to derive low-level TextKit results of the label.
|
||||||
*/
|
*/
|
||||||
public func abstractTextContainer() -> (NSTextContainer, NSLayoutManager)? {
|
public func abstractTextContainer() -> (NSTextContainer, NSLayoutManager, NSTextStorage)? {
|
||||||
|
|
||||||
// Must configure the attributed string to translate what would appear on screen to accurately analyze.
|
// Must configure the attributed string to translate what would appear on screen to accurately analyze.
|
||||||
guard let attributedText = attributedText else { return nil }
|
guard let attributedText = attributedText else { return nil }
|
||||||
@ -533,7 +533,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
textContainer.maximumNumberOfLines = numberOfLines
|
textContainer.maximumNumberOfLines = numberOfLines
|
||||||
textContainer.size = bounds.size
|
textContainer.size = bounds.size
|
||||||
|
|
||||||
return (textContainer, layoutManager)
|
return (textContainer, layoutManager, textStorage)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func boundingRect(forCharacterRange range: NSRange, in label: Label) -> CGRect {
|
public static func boundingRect(forCharacterRange range: NSRange, in label: Label) -> CGRect {
|
||||||
|
|||||||
@ -126,14 +126,12 @@ import UIKit
|
|||||||
/// NOTE: Should only be called when displayed or about to be displayed.
|
/// NOTE: Should only be called when displayed or about to be displayed.
|
||||||
public func alignAccessoryToHero() {
|
public func alignAccessoryToHero() {
|
||||||
|
|
||||||
|
// Layout call required to force draw in memory to get dinmensions of subviews.
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return }
|
guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return }
|
||||||
let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel)
|
let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel)
|
||||||
let rectView = UIView(frame: rect)
|
accessoryView?.center.y = contentView.convert(UIView(frame: rect).center, from: heroLabel).y
|
||||||
heroLabel.addSubview(rectView)
|
|
||||||
accessoryView?.center.y = contentView.convert(rectView.center, from: heroLabel).y
|
|
||||||
heroAccessoryCenter = accessoryView?.center
|
heroAccessoryCenter = accessoryView?.center
|
||||||
rectView.removeFromSuperview()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Traverses the view hierarchy for a 🦸♂️heroic Label.
|
/// Traverses the view hierarchy for a 🦸♂️heroic Label.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user