BumpyClock/agent-templates / skills_archive/apple-platform-skills/swift-ui
swift-ui
UnverifiedSwiftUI and Apple UI engineering: build/refactor views, layout, state/data flow, navigation, platform-specific UI for iOS/iPadOS/macOS/visionOS, AppKit interop, Liquid Glass, toolbars, transitions, and SwiftUI troubleshooting. Use for SwiftUI code changes, UI architecture decisions, Swift concurrency and testing guidance tied to UI, or Apple UI debugging (including log redaction).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.1 KB |
| agents/openai.yaml | config | 174 B |
| references/index.md | markdown | 4.2 KB |
| references/liquid-glass/appkit.md | markdown | 3.3 KB |
| references/liquid-glass/overview.md | markdown | 1.6 KB |
| references/liquid-glass/patterns.md | markdown | 3.9 KB |
| references/liquid-glass/swiftui.md | markdown | 4.0 KB |
| references/logging-private-fix.md | markdown | 8.0 KB |
| references/modern-swift.md | markdown | 4.4 KB |
| references/swift-concurrency.md | markdown | 39.6 KB |
| references/swift-testing-playbook.md | markdown | 35.6 KB |
| references/swiftui.md | markdown | 1.8 MB |
| references/toolbar/swiftui-features.md | markdown | 4.7 KB |
references/liquid-glass/appkit.md
View on GitHub# Liquid Glass in AppKit
## Quick Reference
| Class | Purpose | Key Properties |
|-------|---------|---------------|
| `NSGlassEffectView` | Single glass effect | `contentView`, `cornerRadius`, `tintColor` |
| `NSGlassEffectContainerView` | Multiple glass effects | `contentView`, `spacing` |
## NSGlassEffectView
### Basic Usage
```swift
let glassView = NSGlassEffectView(frame: NSRect(x: 0, y: 0, width: 200, height: 100))
glassView.cornerRadius = 16.0
glassView.tintColor = NSColor.systemBlue.withAlphaComponent(0.3)
glassView.contentView = myContentView
```
### Interactive Glass
```swift
class InteractiveGlass: NSGlassEffectView {
override func mouseEntered(with event: NSEvent) {
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.2
animator().tintColor = NSColor.accent.withAlphaComponent(0.2)
}
}
override func mouseExited(with event: NSEvent) {
NSAnimationContext.runAnimationGroup { _ in
animator().tintColor = nil
}
}
}
```
## NSGlassEffectContainerView
### Container Setup
```swift
let container = NSGlassEffectContainerView()
container.spacing = 40.0 // Merge distance
let contentView = NSView()
container.contentView = contentView
// Add multiple glass views to contentView
[glass1, glass2, glass3].forEach { contentView.addSubview($0) }
```
### Animated Merging
```swift
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.5
// Move glass views closer to trigger merge
glass2.animator().frame.origin.x -= 50
}
```
## Custom Components
### Glass Button
```swift
class GlassButton: NSButton {
private let glass = NSGlassEffectView()
override init(frame: NSRect) {
super.init(frame: frame)
setup()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setup()
}
private func setup() {
bezelStyle = .rounded
isBordered = false
glass.autoresizingMask = [.width, .height]
glass.cornerRadius = 8.0
addSubview(glass, positioned: .below, relativeTo: nil)
}
}
```
### Glass Toolbar
```swift
// Add glass to toolbar area
let toolbar = NSToolbar(identifier: "main")
let glassView = NSGlassEffectView()
glassView.frame = NSRect(x: 0, y: view.bounds.height - 50,
width: view.bounds.width, height: 50)
glassView.autoresizingMask = [.width, .minYMargin]
view.addSubview(glassView)
```
## Best Practices
### Z-Order
- Only `contentView` guaranteed inside effect
- Arbitrary subviews may render incorrectly
### Performance
- Batch in containers when possible
- Limit total glass views (5-10 max)
- Disable when scrolling for performance
### Animation
- Use `NSAnimationContext` for smooth transitions
- Standard duration: 0.2-0.5 seconds
- Animate `tintColor` for state changes
## Common Issues
| Issue | Solution |
|-------|----------|
| Glass not visible | Check view hierarchy, ensure added to window |
| Performance lag | Use containers, reduce glass count |
| Merge not working | Check container spacing value |
| Content outside glass | Use contentView property exclusively |
## See Also
- [Overview](overview.md)
- [SwiftUI Implementation](swiftui.md)
- [Common Patterns](patterns.md)
- [Apple Docs: NSGlassEffectView](https://developer.apple.com/documentation/AppKit/NSGlassEffectView)Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |