I am working on a Swift 4 macOS Application that involves a vibrant dark window and an in-window NSVisualEffectView. Currently, the NSVisualEffectView's color does not quite match that of the window, but it is very close.
How can I make the NSVisualEffectView's color perfectly match the window? My goal is to have the blur effect it provides only appear when content is beneath it, and making it's color match that of the window would create this effect. I have included an image of what is currently happening. You may need to zoom into the image and turn up your display brightness to see the difference. Though it appears minor in this screenshot, the NSVisualEffectView spans the entire window, and on the Retina display of a Mac, the difference is apparent.
I have tried setting the NSVisualEffectView's background color to clear, but that has not worked.
visualEffectView.wantsLayer = true
visualEffectView.layer?.backgroundColor = NSColor.clear.cgColor
I would appreciate any advice on this!
Related
・Purpose
I want to change the color of the padding to match the color of a particular point in the app.
Because I want to make the statesbar change color.
・What I want
Color code for a specific point
If I scroll down and come to the blue part of the image at a specific point, I want to get the blue color code.
===
I have done quite a bit of research and have found no information on how to do that.
Therefore, I would like to know.
The screen in the screenshot is a webView.
I would like to be able to get the color code for a specific point so I can change the color on the webView screen and on the widget.
Currently I have a button that changes the background color of my app (my users complained that it melted into other windows when grey, but others wanted that color scheme). I have 3 color options: grey with black text, light blue with blue text, and purple with white text.
Problem 1:
Dark mode is messing with my color scheme - can I set something up to adjust based on if they have dark mode on? Otherwise, I'm going to have to end up with grey text with a grey background in order for it to be ok when it switches back to grey.
Problem 2:
Button text - this wasn't so bad when using light mode because the buttons didn't change color, but on dark mode, this gets hard to read the button. White text on a light blue background hurts my eyes
I'm unable to attach images due to my level
I'm using Xcode 11.5, swift 5, and I'm coding for a Mac Application
Sounds like you are using the system color for the text / background color. And in dark mode, IOS will automatically change the system color for different mode. For reference:
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/#dynamic-system-colors
Indeed for both problem 1&2, if you want to use custom color (not the system one) for each mode, you can put your color sets into an asset file (and I would suggest adding a new one, rather than adding all color together with your image). For each set of color, set them to the desired appearance (any, light, dark), then set the color by code.
Apple give a detail documentation about that:
https://developer.apple.com/documentation/xcode/supporting_dark_mode_in_your_interface
I am building a small utility app for macOS that combines SpriteKit with AppKit. Specifically, I am using an SKView as the "background" for the app window (mostly for specific types of animations that are easier in SpriteKit). I am also changing colors of the Window's background property to adjust the title bar color. Switching between green and red.
The issue I am running into is matching colors between AppKit and SpriteKit. In short, they don't match. As you can see in the image the title bar is a bit different than the SKView.
After a bit of playing, I found that the background color in the SKView is in the "Device RGB colorspace" and the Window's colors are in "sRGB IEC61966-2.1 colorspace." I changed the AppKit colors to device RGB and the colors still don't match.
I'm creating the colors with a regular old NSColor initializer.
I'm not sure if you can change the color space of a color. The backgroundColor property on the Window and SKView is read only.
Any ideas?
if im reading this right what you are wanting to do is match colors could you not just do something like yourAppKit.backgroundColor = yourSKView.backgroundColor that should set them to equal
and my second question is do you need them to match? most of the time people arent gonna notice and if they do notice they wont really care
also here is some data on converting RGB to sRGB
My guess is that this is due toNSWindow.StyleMask.fullSizeContentView. When this is set, the title bar applies a blur by default.
If you want the colors to be the same, tell the window to use a transparent title bar:
window.titlebarAppearsTransparent = true
I want to place a blur effect on top of a view with gradient. When I do so using the UIVisualEffectView combined with the UIBlurEffect light, I get the following result:
As you can see, the navigation bar is very bright. I'd like it to not be tinted with white color, or what this might be, but instead actually just blur the background.
I noticed that when dragging down the notification center / lockscreen on iOS 11, the blur is not so bright, even though the background gradient is exactly the same:
I was thinking this could be done using the tintColor property of UIVisualEffectView, but changing it did not have any effect whatsoever.
Is there any way I can reproduce the blur effect shown in the image above, using standard Swift libraries?
Edit
Since there haven’t been any responses whatsoever, I’m guessing there’s no way to do it natively.
If someone can recommend a good library, I’m open to that too.
Thanks!
You guys helped so much with my last question, I figured I'd give you a shot at another. I have written an app with a theme that uses a dark blue glassy background and white / gray text and labels. The textfields in my app have clearcolor backgrounds and white texts and everything shows up very well. My only concern is that when you hold down a touch in a text box to get the magnification loupe, of course the white text shows up on a white background... which you can not read. Anybody got any ideas on how to implement a usable loupe here?
Unfortunately, the only "public" way I know how to change the loupe background is by setting textField.backgroundColor
I assume that since you're setting your backgrounds as clearColor, the magnifier defaults to white background, so the only way is to set your backgroundColor as something not clear.
I'm also assuming that since you did mention that you set your backgrounds a clear, that having it not be clear is not an option. So two ways I can think up in my mind about how to get around this is:
Assuming that the magnification lopue gets its background color by calling the backgroundColor implementation (and not some other obscure private API method): override the backgroundColor method and return a solid color.
Create your own loupe (probably not feasible)
I figured out a simple work around that achieved the desired effect. I also went through the full process of making my own loupe but since there is clear documentation on making your own loupe (see kiyoshi's answer), and this other method is ridiculously simple, I decided to document it here. It is basically just faking the clear background so that the white text shows up in the loupe. The background I am using for the view looks like blue smoke on a darker blue background:
alt text http://img231.imageshack.us/img231/9835/beforestatex.jpg
I took a screenshot of the simulator with the textfield visible and a black background so it would show up better:
alt text http://img193.imageshack.us/img193/9023/blackfieldx.jpg
Then I took that screenshot and made it semi transparent in photoshop, and overlayed my original background image to find exactly where the textfield appeared on the background:
alt text http://img266.imageshack.us/img266/9493/transparencyfullscreenx.jpg
Then I copied the exact pixels that would be used as the background of the textfield into a new PNG and saved that and set it as the the background image:
alt text http://img41.imageshack.us/img41/3450/textboxback.png
forwardToField.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:#"textboxback.png"]];
Keep in mind that the image will be repeated as a pattern within the loupe... so if you don't want to see the edges, simply make sure your textfield is larger than the loupe height and width.
Before:
alt text http://img196.imageshack.us/img196/2672/beforex.jpg
After:
alt text http://img23.imageshack.us/img23/2182/afterxd.jpg
I hope this helps somebody out there!
Actually its pretty feasible to create your own loop. Haven't tried subitting to apple yet so don't know how they feel about it.
Basic idea is override touches, use a timer to see how long the user has been touching the screen. The loupe is just a UIView that grabs as an image the view behind it and magnifies it.
Check out this article from Craftymind here
The article has you cache the entire image behind which is definitely faster, for rendering the loupe, but if you have stuff (i.e. textFields) that are constantly changing I've been able to render the loope image real-time without too much of a performance hit.