Hi,
I'm using NSButton and the vibrancy effect works only when the system is in dark mode
How can I get a vibrancy effect also on light mode?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
HI,
Is it possible to add a private framework to the project?
I tried to import MediaRemote.framework but Xcode does not find the framework also when I added the path to the framework in Framework linker
Hi,
How can make auto-scroll label with NSTextField like in the iTunes app?
Thanks!
Hi,
I just add airplay to my app and I tried to stream to my TV but not works
AirPlay code:
//Airplay button
let routePickerView = AVRoutePickerView.init(frame: airplayButton.frame)
routePickerView.isRoutePickerButtonBordered = false
self.view.addSubview(routePickerView)let asset = AVAsset(url: URL(string: "https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8")!)
Hi
How can I detect if user get push notification on macOS?
Thanks!
Hi
I'm trying to resize my NSPanel with spring animation but I have a position problem (the panel is not on center of screen) when I make the panel bigger (see the video)
How can I fix it?
Video:
https://streamable.com/l4281l
func animationBigger () {
let jump = CASpringAnimation(keyPath: "transform.scale")
jump.damping = 60
jump.mass = 10
jump.initialVelocity = 10
jump.stiffness = 200.0
jump.fromValue = 1.0
jump.toValue = 2.0
jump.duration = 0.4
//self is NSPanel
self.contentView?.layer!.add(jump, forKey: nil)
self.setContentSize(bignotchSize)
}
class NotchView: NSView {
private var mouseDownSubject = PassthroughSubject<NSPoint, Never>()
var mouseDownPublisher: AnyPublisher<NSPoint, Never> {
return mouseDownSubject.eraseToAnyPublisher()
}
//Draw notch
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
drawNotch()
}
func drawNotch () {
self.layer?.anchorPoint = CGPoint(x: 0.0, y: 0.0)
let size = self.frame.size
let r: CGFloat = 15.0
let gap: CGFloat = 1.0
let notch = NSBezierPath()
notch.move(to: NSPoint(x: 0.0, y: size.height))
notch.curve(to: NSPoint(x: r, y: size.height - r),
controlPoint1: NSPoint(x: r - gap, y: size.height),
controlPoint2: NSPoint(x: r, y: size.height - gap))
notch.line(to: NSPoint(x: r, y: r))
notch.curve(to: NSPoint(x: 2 * r, y: 0.0),
controlPoint1: NSPoint(x: r, y: gap),
controlPoint2: NSPoint(x: r + gap, y: 0.0))
notch.line(to: NSPoint(x: size.width - 2 * r, y: 0.0))
notch.curve(to: NSPoint(x: size.width - r, y: r),
controlPoint1: NSPoint(x: size.width - r - gap, y: 0.0),
controlPoint2: NSPoint(x: size.width - r, y: gap))
notch.line(to: NSPoint(x: size.width - r, y: size.height - r))
notch.curve(to: NSPoint(x: size.width, y: size.height),
controlPoint1: NSPoint(x: size.width - r, y: size.height - gap),
controlPoint2: NSPoint(x: size.width - r + gap, y: size.height))
notch.close()
NSColor.black.setFill() //change to black to see the notch
notch.fill()
}```
```language
class NotchPanel: NSPanel, CAAnimationDelegate {
private (set) var notchView = NotchView()
var notchClickPublisher: AnyPublisher<NSPoint, Never> {
return notchView.mouseDownPublisher
}
init(_ center: NSPoint,_ size: NSSize) {
let notchFrame = NSRect(x: center.x - 0.5 * size.width,
y: center.y - size.height,
width: size.width,
height: size.height)
super.init(contentRect: notchFrame,
styleMask: [ .nonactivatingPanel,.nonactivatingPanel, .hudWindow],
backing: .buffered,
defer: true)
self.level = .popUpMenu
self.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
self.isOpaque = true
self.isMovable = false //Disable notch to be moveable
self.hasShadow = false //we do custom shadow later
self.backgroundColor = NSColor.systemPink //notch background
setNotchView()
}
private func setNotchView() {
self.contentView?.addSubview(notchView)
notchView.translatesAutoresizingMaskIntoConstraints = false
notchView.leftAnchor
.constraint(equalTo: self.contentView!.leftAnchor)
.isActive = true
notchView.topAnchor
.constraint(equalTo: self.contentView!.topAnchor)
.isActive = true
notchView.rightAnchor
.constraint(equalTo: self.contentView!.rightAnchor)
.isActive = true
notchView.bottomAnchor
.constraint(equalTo: self.contentView!.bottomAnchor)
.isActive = true
}```
Hi,
Is it possible to change the anchorpoint of NSView if I don't use layer?
If not how can I use layer and still draw my notch?
import Cocoa
import Combine
class NotchView: NSView {
private var mouseDownSubject = PassthroughSubject<NSPoint, Never>()
var mouseDownPublisher: AnyPublisher<NSPoint, Never> {
return mouseDownSubject.eraseToAnyPublisher()
}
//Draw notch
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
drawNotch()
}
func drawNotch () {
let size = self.frame.size
let r: CGFloat = 16.0
let gap: CGFloat = 1.0
let notch = NSBezierPath()
notch.move(to: NSPoint(x: 0.0, y: size.height))
notch.curve(to: NSPoint(x: r, y: size.height - r),
controlPoint1: NSPoint(x: r - gap, y: size.height),
controlPoint2: NSPoint(x: r, y: size.height - gap))
notch.line(to: NSPoint(x: r, y: r))
notch.curve(to: NSPoint(x: 2 * r, y: 0.0),
controlPoint1: NSPoint(x: r, y: gap),
controlPoint2: NSPoint(x: r + gap, y: 0.0))
notch.line(to: NSPoint(x: size.width - 2 * r, y: 0.0))
notch.curve(to: NSPoint(x: size.width - r, y: r),
controlPoint1: NSPoint(x: size.width - r - gap, y: 0.0),
controlPoint2: NSPoint(x: size.width - r, y: gap))
notch.line(to: NSPoint(x: size.width - r, y: size.height - r))
notch.curve(to: NSPoint(x: size.width, y: size.height),
controlPoint1: NSPoint(x: size.width - r, y: size.height - gap),
controlPoint2: NSPoint(x: size.width - r + gap, y: size.height))
notch.close()
NSColor.systemPink.setFill() //change to black to see the notch
notch.fill()
}
//Tap with mouse
override func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
//move notch to top
mouseDownSubject.send(event.locationInWindow)
}
}
Hi,
Is it possible to handle touchbar volume slider (not volume buttons)
I want to print hello when the user use volume slider on touchbar
Hi,
What is the best way to make this animation with Swift and UIKit?
[Animation:](https://dribbble.com/shots/4247369-Loading-notch
/)
Thank you!
How is it possible to remake the Dynamic Island music spectrum (visual EQ) animation on macOS? I see WhatsApp have a similar animation on voice calls. Is there a 3rd or native Apple library to make it?
https://imgur.com/a/PKDkosC
Hi,
How is it possible to make NSProgressIndicator smaller ?
When I use style property the thickness is also change
This is the size that I want (it's from Xcode) it's with regular size style but it's smaller in size
And this is my attempt
Hi,
I'm using NSSplitViewController and once I load a viewcontroller with scrollview the IBActions of NSSwitch,NSButtons etc not work after I added the scrollview
How can I fix it?
import Foundation
//Categories Protocal delegate
protocol CategoriesViewControllerDelegate: AnyObject {
func didSelectCategory(category: String)
}
class DetailViewController:NSViewController, NSOutlineViewDataSource, CategoriesViewControllerDelegate {
weak var delegate: CategoriesViewControllerDelegate?
override func viewDidLoad() {
// Other setup code...
detViewController = self
loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self)
}
func didSelectCategory(category: String) {
// Handle the selected category in DetailViewController
print("Selected category: \(category)")
// Load the corresponding view controller or perform any other actions
switch category {
case "General":
// Load GeneralSettingsViewController
// Example: self.replaceCurrentViewController(with: GeneralSettingsViewController())
print("Load GeneralSettingsViewController")
loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self)
case "DynaMusiX":
// Load DynaMusicSettingsViewController
// Example: self.replaceCurrentViewController(with: DynaMusicSettingsViewController())
print("Load DynaMusicSettingsViewController")
loadViewControllerWithScrollView(DynaMusicSettingsViewController.self, storyboardIdentifier: "DynaMusicSettingsViewController", originalViewController: self)
case "DynaGlance":
// Load DynaGlanceSettingsViewController
// Example: self.replaceCurrentViewController(with: DynaGlanceSettingsViewController())
print("Load DynaGlanceSettingsViewController")
loadViewControllerWithScrollView(DynaGlanceSettingsViewController.self, storyboardIdentifier: "DynaGlanceSettingsViewController", originalViewController: self)
default:
break
}
}
}
//Load viewcontroller with scrollview
func loadViewControllerWithScrollView<T: NSViewController>(_ viewControllerType: T.Type, storyboardIdentifier: String, originalViewController: NSViewController) {
let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil)
let newViewController = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(storyboardIdentifier)) as! T
// Remove existing child view controllers
for childVC in originalViewController.children {
childVC.removeFromParent()
childVC.view.removeFromSuperview()
}
// Wrap the new view controller's view in a scroll view
let scrollView = NSScrollView()
scrollView.documentView = newViewController.view
scrollView.autoresizingMask = [.width, .height]
scrollView.hasVerticalScroller = true
scrollView.hasHorizontalScroller = false
scrollView.contentView.scroll(to: NSPoint(x: 0, y: newViewController.view.frame.height))
scrollView.translatesAutoresizingMaskIntoConstraints = true
// Set user interaction for the content view inside the scroll view
scrollView.documentView?.translatesAutoresizingMaskIntoConstraints = true
scrollView.documentView?.needsLayout = true
// Add the scroll view as a subview of the original view controller
originalViewController.view.addSubview(scrollView)
scrollView.frame = originalViewController.view.bounds
scrollView.layer?.zPosition = -1
}
t
Hi,
How can I improve the CPU usage of my auto scrolling text (horizontal)? Currently I use very short timer
Thank you
Code: https://codeshare.io/Q8A1JJ
REMOVED
Hi,
I'm not sure why but when my fileURL is .jpg file and I drop the file from my app to Finder folders it make the dropped file as .jpeg
Is there a way to fix it?
[.onDrag {
if FileManager.default.fileExists(atPath: file.path) {
// Provide the file as an item for dragging
let fileURL = URL(fileURLWithPath: file.path)
let itemProvider = NSItemProvider(contentsOf: fileURL)
// Remove the file extension in the suggestedName
let baseNameWithoutExtension = fileURL.deletingPathExtension().lastPathComponent
itemProvider?.suggestedName = baseNameWithoutExtension
return itemProvider ?? NSItemProvider()
} else {
// Handle the case where the file no longer exists
print("File no longer exists at path: \(file.path)")
return NSItemProvider()
}
})