Hi,
on my macOS app I would like to set the window background color as the titlebar background color such a way to get a unique color all over the window on both light and dark mode.
But I cannot find the way to read the titlebar background color nor I found a standard color name for that. How can I do that?
Post
Replies
Boosts
Views
Activity
Yesterday I abandoned Catalina and Xcode 12.3 and installed Big Sur 11.2 (20D64) and Xcode 12.4 on my MacBook Pro 16" top config.
Now compiling my app is twice slower, when I select and work on a XIB file the fans begin to run fast and noisy and at any compile-launch I get 57 log messages like this
ScanAllPluginsInLibrary: load Library [/System/Library/Filesystems/NetFSPlugins]
The are many other smaller troubles but let's focus on these ones. What does it mean ScanAllPluginsInLibrary ? I have been searching on Google and found nothing explaining.
I have added a NSWindow child to a main NSWindow to simulate a NSDrawer (since it has been deprecated).
[mainWindow addChildWindow:drawer ordered:NSWindowBelow];
drawer.contentView.wantsLayer = YES;
drawer.contentView.layer.backgroundColor = [NSColor clearColor].CGColor;
drawer.contentView.layer.masksToBounds = YES;
drawer.contentView.layer.cornerRadius = 10.0;
Then I animate the drawer to the left/right to open/close it. It works well. Since I need only 2 rounded corners I have setup two conditions: when the drawer opens to the right side of the main window and when it opens to the left side.
if(drawer.mSide == kSideRight){
drawer.contentView.layer.maskedCorners = kCALayerMaxXMinYCorner | kCALayerMaxXMaxYCorner;
}
else{
drawer.contentView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMinXMaxYCorner;
}
It works well at the first settings. If I later change side, as I change the maskedCorners as shown here above, I still see the drawer with the proper rounded corners but I also see an unwanted tiny dark "squared" border around the window, even close to the rounded corners.
How can I update the layer to properly show the rounded corners without that squared border around the whole window?
I have set up a NSToolbarItem containing a NSMatrix (2 buttons to toggle). On Catalina it looks well. On Big Sur, I get an unwanted space between the two (smaller) buttons. My settings:
NSToolbarItem
Size: Explicit
Minimum Width 74
Minimum Height 37
Maximum Width 74
Maximum Height 37
NSMatrix
Cell Size 37 x 37
Cell Spacing 0 x 0
Automatic Resizes Cells: YES
Auto Recalculates Cell Size: NO
Control Size: Regular
View Frame: 74 x 37
Layout: Autoresizing Mask (All)
The two icons size are 74 x 74 pixels.
The toolbar height on Big Sur is smaller, so I end up with the single button size as 30 x 30 pixels and a matrix size as 60 x 30 plus an unwanted 14 pixels space between the two buttons.
If I set the Minimum size to 60 x 30 pixels, it works well on Big Sur, but I get a smaller NSMatrix on Catalina.
So, how to fix this trouble?
At launch I get this Log message:
NSToolbarItem.minSize and NSToolbarItem.maxSize methods are deprecated. Usage may result in clipping of items. It is recommended to let the system measure the item automatically using constraints.
But how to add constraints on IB to the NSToolbarItem only? The whole XIB file has no constraints.
I can quite move my macOS app's main window from my built-in Retina display to my external monitor (Samsung TV normal resolution) and everything works well because
mScaleDisplay = [[NSScreen mainScreen] backingScaleFactor];
gives me the proper values: 2.0 on my Retina display and 1.0 on the Samsung TV. So I can properly set up the content of the window.
Anyway it doesn't work on my customer's monitor 4K by LG (lg-27UD59-B) and macOS 10.14.1 Mojave. He sees a big image as it was a 1:1 resolution monitor.
So I ask: how could I detect the resolution of this monitor?
I export a series of still images to a movie using AVFoundation.
Despite I always set the codec to AVVideoCodecTypeAppleProRes4444, sometimes I get a movie with the AppleProRes4444 format, and sometimes, if I change the image sources, I get a movie with the H.264 format.
I never change the codec, so I would like to know whether AVFoundation can autonomously change my codec.
If no, as I presume, I would like to understand what I miss here.
videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:moviePath] fileType:AVFileTypeQuickTimeMovie error:&error];
NSParameterAssert(videoWriter);
if(videoWriter == nil) return NO;
NSString						*codec = AVVideoCodecTypeAppleProRes4444;
NSMutableDictionary *videoSettings = [NSMutableDictionary dictionaryWithObjectsAndKeys:
codec, AVVideoCodecKey, width, AVVideoWidthKey,
height, AVVideoHeightKey, nil];
videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
NSParameterAssert(videoWriterInput);
if(videoWriterInput == nil) return NO;
NSDictionary *bufferSettings = [NSDictionary dictionaryWithObjectsAndKeys:NumI(kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange), kCVPixelBufferPixelFormatTypeKey, nil];
adaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:videoWriterInput sourcePixelBufferAttributes:bufferSettings];
if(adaptor == nil) return NO;
NSParameterAssert([videoWriter canAddInput:videoWriterInput]);
videoWriterInput.expectsMediaDataInRealTime = YES;
[videoWriter addInput:videoWriterInput];
[videoWriter startWriting];
[videoWriter startSessionAtSourceTime:kCMTimeZero];
/* Then I add the images with */
[adaptor appendPixelBuffer:buffer withPresentationTime:CMTimeMake((int64_t)counter, (int32_t)fps)];
/* I previously created the buffer with */
CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, nil, &bufferRef);
aRGBABuffer = CVPixelBufferGetBaseAddress(bufferRef);
rowBytes = CVPixelBufferGetBytesPerRowOfPlane(bufferRef, 0);
aRGBAContext = CGBitmapContextCreate(aRGBABuffer, iWidth, iHeight, 8, rowBytes, CGColorSpaceCreateDeviceRGB(), (CGBitmapInfo)kCGImageAlphaPremultipliedLast);
I would like to detect whether my macOS app executable file has been altered by someone. I wouldn't rely on the Codesign because, as I have seen on the web, many apps have been cracked, even if notarised by Apple, even the Apple apps. I know my method will not guarantee the top security, but I would add this custom protection anyway.
A) If I manually add a checksum file within the Resources folder in the bundle after the app has been Archived (so within the xcarchive package), it's too late. The app won't launch on macOS 10.15.6 because of the manipulation. I get a crash with "Termination Reason: Namespace CODESIGNING, Code 0x2".
B) If I manually add or modify the checksum file after the app has been notarised, the same, it won't launch.
C) If I modify the checksum resource file with a shell script during the build phase, before the "Run Copy Bundle Resources" phase, the checksum is wrong since the executable at that moment has a different file size and file modification date.
D) Even the Terminal commands
codesign --remove-signature Foo.app
codesign -s "MyIdentity" Foo.app
modify the executable file (file size and modification date, therefore even the checksum), so I can't use my checksum file created before the latest Terminal command…
So, what's the best way to add my own checksum file to my app bundle? I run macOS 10.15.6 and XCode 11.5 and compile my 64 bits app for macOS 10.3/10.5.