Lots of examples on how to do create a glow effect on iOS UIView, but how do you do it on macOS? Preferably in Swift.
Thanks.
Your question is a little vague (in particular, what is a "glow effect"?), but what I think you mean is a shadow effect with a light colour instead of a dark colour.
For this, you merely have to configure the NSView layer's shadow property, as per the documentation at:
https://developer.apple.com/reference/appkit/nsview/1483263-shadow
Give the shadow a (0,0) offset to centre it behind the view, give it a decent radius around the edge of the view, and give it a light glowing colour, and appropriate opacity.
Complete code example is at: How to display shadow for NSView?
If shadow is not what you're after, you may need to edit your question and elaborate on what you mean.
Related
I need to create UIImage (bitmap?) filled with a solid colour so that it can be tinted and thus support Dark and Light mode changes
Is there a way to do this in Swift?
Not the best way, but a quick and dirty way to do this would be make a UIView with a background the color you want and then use one of the many ways to go UIView -> UIImage.
This stack overflow question here does exactly that:
How to convert a UIView to an image
Furthermore, looking at that code will give you some insights on how to do it the right way, with lower level graphics functions if you like.
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!
I have a button which when touched, I would like it to shrink and darken slightly. It's easy enough to shrink the button (SKAction.scaleTo), but I can't seem to find a way of darkening it (I'm not actually sure if it is possible to darken a sprite with an SKAction).
I can add a solid black sprite over the top of the button and adjust the alpha to darken when touched, but before I implement this into my code, I just wanted to make sure there wasn't something simpler available that I just haven't discovered yet.
SKAction.colorizeWithColor or SKAction.colorizeWithBlendFactor may help you
I'm trying to achieve a sort of dynamic UIView masking effect. Here is a sketch:
So as you can see, I'm trying to create a UIView that can effectively cut through an image to reveal the image behind it. I already know how to return an image with a mask statically, however I would like the "revealer" to be draggable (I'll use pan gesture) and live.
Does anyone have any ideas or starting points on how to achieve this? Thanks
(NOTE: My demo says White layer, but I'd actually like to show another image or photo).
masking an image is not that difficult.
This link shows the basics.
http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html
But personally I think i would make 2 UIImage views and crop the content of the draggable UIView. I'm not sure but I would expect that clipping and panning the second image will be less computationally expensive then applying the mask and will get you a better frame rate.
So I would do: UIImageView of the full image. A UIView on top of it with a white and some transparency setting to make it look white, then a UIImageView with the image either places or cropped so that only the correct section is showing.
I am trying to add a thick shadow to a UILabel, without any blur. In photoshop I would use the "Spread" option to make the shadow look like this. It's for a comic book themed UI in an app I am developing. I cannot use images as the text is dynamic and different for each user.
Here is what I am after (on the left) and here is as far as I have gotten so far with CGShadowWithColor (on the right):
Anyone know how I can achieve this result?
A quick hack to try would be to have several black UILabels below the white one, each offset slightly.