diff --git a/Projects/NeonExample/TextViewController.swift b/Projects/NeonExample/TextViewController.swift index fb12abb..9983105 100644 --- a/Projects/NeonExample/TextViewController.swift +++ b/Projects/NeonExample/TextViewController.swift @@ -12,12 +12,18 @@ import Neon import NSUI final class TextViewController: NSUIViewController { - let textView = NSUITextView(usingTextLayoutManager: false) - let highlighter: TextViewHighlighter + private let textView: NSUITextView + private let highlighter: TextViewHighlighter init() { + if #available(iOS 16.0, *) { + self.textView = NSUITextView(usingTextLayoutManager: false) + } else { + self.textView = NSUITextView() + } + // enable non-continguous layout for TextKit 1 - if textView.textLayoutManager == nil { + if #available(macOS 12.0, iOS 16.0, *), textView.textLayoutManager == nil { #if canImport(AppKit) && !targetEnvironment(macCatalyst) textView.layoutManager?.allowsNonContiguousLayout = true #else diff --git a/Sources/Neon/PlatformTextSystem.swift b/Sources/Neon/PlatformTextSystem.swift index 2b833dd..f3b9e2c 100644 --- a/Sources/Neon/PlatformTextSystem.swift +++ b/Sources/Neon/PlatformTextSystem.swift @@ -44,7 +44,7 @@ extension NSTextContentManager: VersionedContent { extension NSTextContainer { func textRange(for rect: CGRect) -> NSRange? { - if #available(macOS 12.0, *), textLayoutManager != nil { + if #available(macOS 12.0, iOS 15.0, *), textLayoutManager != nil { return nil } @@ -59,7 +59,7 @@ extension NSTextContainer { extension TextView { var tk2VisibleTextRange: NSRange? { guard - #available(macOS 12.0, *), + #available(macOS 12.0, iOS 16.0, *), let textLayoutManager, let viewportRange = textLayoutManager.textViewportLayoutController.viewportRange, let textContentManager = textLayoutManager.textContentManager