I'm trying out the new "Visual effect with Blur" in xCode and am noticing the visual artifact in the attached image. I tried different combinations of constraints and see that
Here's the issue I'm seeing - the UILabel's frame is outlined in a different color. How can I make sure that the label has a transparent background, but still gets the vibrancy effect when using "Visual Effect with Blur and Vibrancy"?
Make sure both the UILabel and any view behind has Background set to Clear/Default color.
Related
I'm presenting a view in an NSPopover, using code based on this sample code.
The view, and all of its sub-views, are layer-backed. There's a single NSImageView, and several non-editable NSTextFields. The text fields backgroundColors are set to [NSColor textBackgroundColor], and their textColors to [NSColor textColor]. In this way, the text is black if one is using the normal theme, and white if one is using the "dark menu bar and Dock" option (which I'll refer to as "dark theme" from now on). This all works fine, and it looks a little somethin' like this:
Light theme:
Dark theme:
The problem comes when I animate the NSImageView up off the view. As it intersects with the NSTextFields, the image appears to blend with the text fields in an unappealing manner. It happens in both light and dark themes, but it's more icky-looking (it's a technical term) in the dark theme. Dig it:
The code to animate it looks basically like this:
CABasicAnimation* positionAnimation = [CABasicAnimation animationWithKeyPath:#"position"];
positionAnimation.fromValue = [NSValue valueWithPoint:fromPoint];
positionAnimation.toValue = [NSValue valueWithPoint:toPoint];
positionAnimation.duration = imageAnimationDuration;
[self.imageView.layer addAnimation:positionAnimation forKey:#"position"];
self.imageView.layer.position = toPoint;
What have I tried? Oh, what haven't I tried?
First off, my own views don't have any kind of NSVisualEffectView going on. But it seems that NSPopover adds that on its own; you can clearly see my desktop bleeding through the popover in the animation above. That's fine; it's actually a nice effect. But, thinking that my NSImageView was trying to be vibrant, I subclassed NSImageView just to return NO from allowsVibrancy. No change in behavior.
Next, I subclassed NSView to return NO from allowsVibrancy, and made the parent view of my view an instance of that. No change in behavior.
My NSTextFields are set with drawsBackground = NO, so I changed them to YES. No change in behavior. Then, leaving drawsBackground = YES, I set both text field's backgroundColors to [NSColor clearColor]. Here's where it gets weird. This does make the weird drawing go away, but it changes the text color of one of the text fields (the smaller one) to black. Wut? See below.
I gave up on the background colors, and started messing with the text colors. I found that if I set the textColor of the text fields to a discrete color (say, [NSColor blackColor] or [NSColor whiteColor], then the weird drawing problem also goes away. It seems only to get weird when using colors which adapt with the theme such as [NSColor textColor]. That's super lame, because the whole point of using something like [NSColor textColor] is that it adapts to the theme. I could probably hack around and figure out what theme is active and set the colors manually, but I really don't want to go that route if I can help it.
I promise there's a question in here somewhere, and, mercifully, here it is:
How can I fix the animation issue shown above, while still using colors which properly adapt to the current theme?
Sample project on GitHub.
Edit:
The desired result is to have no blending between the image and the text. Something like this:
The image I used in the sample app here maybe isn't the best example to convey the sheer yuckiness of the animation I'm seeing in my actual app. The image in the sample is already mostly white, while in my actual app it's mostly black, and it truly looks horrible when blended with white text.
Visual Effect Views (like used in NSPopover) are totally messed up in OS X Yosemite and they are causing your problem here. It is not your fault, these views are totally buggy.
A workaround on Yosemite should be to set the appearance property of each NSTextField to NSAppearanceNameAqua. Because if the labels don't try to do some weird vibrancy effect, they can't mess things up. The labels still look the same and the strange effect is gone.
My words in code:
self.titleLabel.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
self.descriptionLabel.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
Luckily NSVisualEffectView's are working fine now in El Capitan. So your code should work fine there..
I have a NSPopover containing a NSOutlineView (source list) that is displayed over a usually dark background (but it's not always dark). The NSOutlineView has a transparent background to blend nicely with the NSPopover view. This looked great in OS X 10.9 but in 10.10 the system changes the text color in the NSOutlineView based on the background. The result is that the text becomes completely gray and unreadable in some cases:
If I change the popover to be HUD style it is more readable:
However, in this case, it becomes problematic with lighter backgrounds (the top).
Is there any way to control the text color in the NSOutlineView so that the color stays the same no matter the background? I have tried setting the color of the text cell to black instead of the system colors but it does not help.
Also, can I control/remove the transparency of the NSPopover? I have read that NSPopover makes use of NSVisualEffectView, which has some appearance controls, but I don't know how to access it from NSPopover.
For aesthetic reasons I do not want to put the NSOutlineView under a solid background view. In this case there will be a ugly mismatch in color between the popover background and its arrow.
EDIT:
I was able to remove the transparency using the following code:
NSView *popoverView = popover.contentViewController.view.superview;
popoverView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
It works but feels like a ugly hack. I welcome better suggestions.
EDIT2:
This is what it looks like with the aqua style. No transparency and black text.
Set the mode to something different other than source list and you should get the pre-10.10 style, i.e. without the translucency.
I'm using NSPopover, and when I change the system dock color to dark (Yosemite new feature) some elements in my view invert their color.
For example some labels changes from black to grey, or text fields background changes from white to black. And if I have a view with white background it is now changes to the blurred dark effect.
So two questions:
Can I cancel this behaviour and force the UI to act like in regular mode?
Is there any rules here which element invert their color?
Because it seems that some element changes and some not.
This is my app in Yosemite regular mode:
And this is in Yosemite dark mode:
It might be a library you're using that's causing this behavior. I just tested on a new project and I couldn't make the NSPopover black no matter how hard I tried.
What libraries are you using ? How did you set up your NSPopover ?
Maybe you could try changing the appearance property of the view ?
view.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
NSView has the property appearance because it conforms to NSAppearanceCustomization.
Also see NSAppearance.
————————————————————————
Found the solution:
self.popover.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
the result:
There are ways to do this, though I would recommend embracing it.
It's not concretely documented what will change and how.
But observation will show you what to do.
Primarily it requires you do the opposite of opting in.
Opting in is using Appkit interface elements as is as well as using the NSColor names provided as system colors and using the NSVisualEffectView.
That means to explicitly opt out you need to go around and basically customize views and that mostly means setting explicit colors and occasionally subclassing.
Out of the box HUD style popovers and panels would be opting in.
The recent release of iOS 7 includes a change to UIPopoverController where the popovers are now flat, with no shading underneath (none of the betas for iOS 7 included this change - the change only appeared with the GM release). Unfortunately this change is really not working with our iPad application; without the shading effect and the dark border, our popover is blending in with the underlying screen.
Do I have any options at all as far as customizing this effect or (even better) making popover look the way it used to look?
Take a look at popoverBackgroundViewClass. Not sure this will give you the result you are looking for, however. When a popover is displayed, the system dims the background view hierarchy, but there are no shadows underneath the popover. If this is not enough, you should look at implementing a custom popover controller or using an open source.
We are using a UITextView with a dark background. As such we have made the text white color in order to be easier to read. The problem is the magnify window that pops up when you hold down your finger to move the insertion point uses white for the text color as well. This makes it impossible to see exactly where the insertion point is.
Is it possible to independently control the text color used in the magnify window?
Here is a screen shot illustrating the problem.
I just did a quick test in here and it's working fine.
I tested with firmware 2.2.1, in the simulator and using a device.
This is what I did to test it:
1- Created a new View-Based project
2- edited the nib in the Interface Builder, added a UITextView, setting the text to white and the background to gray, leaving everything else default
Do you have something different?
Hmm, it works correctly in the Notes app. Not only is the background yellow, you also see the lines.
Maybe it depends on whether you set the background color directly on the UITextView or make it transparent and set the background color of its containing view?
I don't think you have any control over that. And I think you should file a bug report with Apple over that. It should be smarter than that.