Apparently, `NSTextAttachment` is very limited in what it can do. Simple things like opacity and scale hover effects aren't possible by default. That's a bummer... 😔
Luckily, I just learned about `NSTextAttachmentViewProvider`, and this one seems to support embedding interactive views in text. This means, I should be able to have a SwiftUI view embedded directly in the `NSTextView`.
This SwiftUI view will contain an image with some beautiful animations such as:
```swift
.opacity(isHovering ? 0.85 : 1.0)
.scaleEffect(isPressed ? 0.97 : 1.0)
.animation(.easeInOut(duration: 0.15), value: isHovering)
.animation(.spring(response: 0.2, dampingFraction: 0.6), value: isPressed)
```
#dev #Swift #SwiftUI #AppKit
nostr:nevent1qvzqqqqqqypzp8yls8khjhc0tma9tzfjsfrg0kz0cln2fnaxmdwk6w6sljmlltkzqy8hwumn8ghj7mn0wd68ytnddaksz9rhwden5te0dehhxarj9ehhsarj9ejx2aspz3mhxue69uhhyetvv9ujuerpd46hxtnfduq3vamnwvaz7tmjv4kxz7fwdehhxarj9e3xzmnyqqspnsavkxla7vxs3rnmw7rcec70klcz6rpsn6dgqfg9qagj6jrhrfgx2xsf5
Login to reply