mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 03:40:18 +00:00
36 lines
991 B
Swift
36 lines
991 B
Swift
import Foundation
|
|
import UIKit
|
|
import AsyncDisplayKit
|
|
|
|
public class EditableTextNode: ASEditableTextNode {
|
|
override public var keyboardAppearance: UIKeyboardAppearance {
|
|
get {
|
|
return super.keyboardAppearance
|
|
}
|
|
set {
|
|
guard newValue != self.keyboardAppearance else {
|
|
return
|
|
}
|
|
super.keyboardAppearance = newValue
|
|
self.textView.reloadInputViews()
|
|
}
|
|
}
|
|
}
|
|
|
|
public extension UITextView {
|
|
var numberOfLines: Int {
|
|
let layoutManager = self.layoutManager
|
|
let numberOfGlyphs = layoutManager.numberOfGlyphs
|
|
var lineRange: NSRange = NSMakeRange(0, 1)
|
|
var index = 0
|
|
var numberOfLines = 0
|
|
|
|
while index < numberOfGlyphs {
|
|
layoutManager.lineFragmentRect(forGlyphAt: index, effectiveRange: &lineRange)
|
|
index = NSMaxRange(lineRange)
|
|
numberOfLines += 1
|
|
}
|
|
return numberOfLines
|
|
}
|
|
}
|