How to set the size of an NSToolbarItem on macOS Ventura since setMaxSize is deprecated?

269 Views Asked by At

Everything works as expected when using [toolbarItem setMaxSize: NSMakeSize(24,24)]- but this function is deprecated now.

I tried to set the layout constraints on the items's view but that does not have any effect.

        NSView *itemView = toolbarItem.view;
        itemView.translatesAutoresizingMaskIntoConstraints = NO;

        NSLayoutConstraint *widthConstraint = [itemView.widthAnchor constraintEqualToConstant: 24];
        NSLayoutConstraint *heightConstraint = [itemView.heightAnchor constraintEqualToConstant: 24];

        widthConstraint.active = YES;
        heightConstraint.active = YES;
0

There are 0 best solutions below