GradientView | Easily use gradients in UIKit for iOS & tvOS | iOS library
kandi X-RAY | GradientView Summary
kandi X-RAY | GradientView Summary
Easily use gradients in UIKit for iOS & tvOS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of GradientView
GradientView Key Features
GradientView Examples and Code Snippets
Community Discussions
Trending Discussions on GradientView
QUESTION
Problem:
I have a View
that I needed to place multiple (2) views that contained: 1 Image
+ 1 Text
. I decided to break that up into a ClickableImageAndText
structure that I called on twice. This works perfectly if the image is a set size (64x64) but I would like this to work on all size classes. Now, I know that I can do the following:
ANSWER
Answered 2021-Dec-29 at 14:49The possible solution is to use screen bounds (which will be different for different phones) as reference value to calculate per-cent-based dynamic size for image. And to track device orientation changes we wrap our calculations into GeometryReader
.
Note: I don't have your images, so added white borders for demo purpose
QUESTION
This is a custom UIView subclass for a tableHeaderView.
I'm currently trying to put a gradient to an UILabel that's in a vertical UIStackView. It works really well without gradient even in RTL languages (gets moved to the right), but as soon as I add the gradient, the label that's the maskView of the gradientView gets completely out of its place. Here the code for better comprehension:
...ANSWER
Answered 2021-May-06 at 15:07The problem is that your gradientView
has no intrinsic content size.
Try changing your constraints to this:
QUESTION
I have tried to use Buttons and Navigation Links from various examples when researched on this channel and on the net. The NavigationLink would be ok, except that the NavigationView is pushing everything down in my view.
I have a view that contains an image and a text like this: ( x Close) but when I use the code below, the Close button is not doing anything.
In ContentView()
I have a (?) button that takes me from WalkthroughView()
, then to the PageTabView, then to this view, TabDetailsView:
ContentView():
...ANSWER
Answered 2021-Jan-02 at 05:27QUESTION
My question requires quite a bit of explanation. If you want to skip to the question, look for the bold "Question:" towards the end.
It's fairly easy to create a "circle wipe" animation in iOS or Mac OS using a Core Animation and masks.
One way is to install a CAShapeLayer as a mask on a view (typically an image view), and installing a circle in the shape layer, and animating the circle from 0 size to large enough to cover the whole image (r = sqrt(height^2 + width^2
)
Another way is to use a radial CAGradientLayer as a mask, set up the center of the gradient as an opaque color, and have a sudden transition to clear just beyond the corners of the image. You then animate the "positions" values of the gradient layer to move the clear color in to the center of the image.
Both of these approaches create a sharp-edged "circle wipe" that causes the image to shrink to a point and disappear.
That effect looks like this:
The classic cinematic circle wipe animation has a feathered edge, however, rather than a sharp border. The outer edge of the circle is completely transparent. As you move in towards the center the image becomes more and more solid over a fairly short distance, and then the image is completely opaque from there into the center. As the circle shrinks, the thickness of the transition from transparent to opaque remains constant, and the circle stinks down to a point and disappears. (The mask is a circle is opaque in the middle and has a slightly blurred edge, and the radius of the circle shrinks to 0 while the thickness of the blurred edge remains constant.)
Here is an example of an old school circle wipe. This is technically an "Iris Out" where the transition is to black, but the idea is the same:
https://youtu.be/IqDhAW3TDR8?t=90
I have no idea how to achieve a circle wipe with a feathered edge using a shape layer as a mask. Shape layers are always sharp-edged. I could get fairly close by using a shape layer where the circle is stroked with 50% opacity, and the middle of the circle is filled with a color at 100% opacity, but that wouldn't get the smooth transition from transparent to opaque that I'm after.
Another approach I've tried is using a radial gradient with 3 colors in it. I set the inner colors as opaque, and the outer color as clear. I set the location of the outer color as > 1 (say 1.2), the middle location to 1, and the inner location to 0. The locations array contains [1.2, 1.0, 0]
That makes the whole part of the mask that covers the image opaque, with a feathered transition to clear that happens past the edges of the image.
I then do an animation of the locations array in 2 steps.
In the first step, I animate the locations array to [0, 0, 0.2]
. That causes a band of feathering to move in from the corners and stop at 0.2 from the center of the image.
In the 2nd step, I animate the locations array from [0, 0, 0.2]
to [0,0,0]
. That causes an inner, transparent-to-opaque center to shrink to a point and disappear.
The effect is ok, and if I run it with a narrow blur band and a fast duration, it looks decent, but it's not perfect.
Here is what it looks like with a blur range of 0.2, and a duration of (I think) 0.25 seconds:
If I introduce a pause between the animation steps, however, you can see the imperfections in the effect:
Question: Is there a way to animate a circle with a small blur radius (5 points or so) from the full size of a view down to 0 using Core Animation?
The same question applies to other types of wipe animations as well: Keyhole, star, side wipe, box, and many others. For those, the radial gradient trick I'm using for a feathered circle wipe wouldn't work at all. (You create those specialized wipe animations using a CAShapeLayer that's the shape you want to animate, and then adjust it's size from large to small.
It would be easy to create a static blurred circle (or other shape) by first drawing a circle and then applying a Core Image blur filter to it, but there's no way to animate that in iOS, and the CI blur filter is too slow on iOS even if you could.
Here is a link to the project I used to create the animations in this post using the 3-color radial gradient I describe: https://github.com/DuncanMC/GradientView.git.
Edit:Based On James' comment, I tried using a shape layer with a shadow on it as a mask. The effect is on the right track, but there is still a stark transition from the opaque part of the image to the mostly transparent part which is masked by the shadow layer. Even with a shadow opacity of 1.0 the shadow is still mostly transparent. Here's what it looks like:
Making the line color of the circle shape partly transparent helps some, and gives a transition between the opaque part of the image and the mostly transparent shadow. Here's the image above but stroking the shape layer at a line width of 2 points and an opacity of 0.6:
Edit #2: SOLVED!James' idea of using a shadowPath is the solution. You don't want anything in your mask layer other than a shadowPath. If you do that you can use the shadowRadius property to control the amount of blurring, and smoothly animate a shadow path from a circle that fully encloses the view down to a vanishing point all in one step.
I've updated my github project at https://github.com/DuncanMC/GradientView.git to include both the radial gradient animation and the shadowPath animation for comparison.
Here is what the finished effect looks like, first with a 5 pixel blur radius:
And then with a 30 pixel blur radius:
...ANSWER
Answered 2020-Sep-09 at 10:13You could use the shadowPath
on a CAShapeLayer
to create a circle with a blurred outline to use as the mask.
Create a shape layer with no fill or stroke (we only want to see the shadow) and add it as the layer mask to your view.
QUESTION
To apply a gradient to a NSView, it seems best to make a class that inherits from NSView and override the draw method that sets a path and draws the gradient.
...ANSWER
Answered 2020-Aug-26 at 16:17With this above method, I am limited to defining two (the startColor & startPosition and endColor & endPosition) only.
No, you're not. This is a variadic; you can add as many tuples as you wish. This works fine:
QUESTION
I have 2 recycler views and a view pager in a fragment. Everything else works fine but both recycler view items are showing a random mark on the upper left corner of every items. And same thing is happening for the view pager items.
This fragment is in a fragment activity and view pager is using pager adapter. And I am using Picasso library to load images on the items and also using network policy to cache the images in disk.
recycler view items appearing like this
view pager items appearing like this
Recycler View adapter
...ANSWER
Answered 2020-Aug-08 at 08:42When loading image using Picasso use: setIndicatorsEnabled(false)
QUESTION
I want to perform animation(full view height to 88px height, bottom to top animation) when viewController is loaded. So I have added a UIView(animationView)on the storyboard, added gradient programmatically in viewDidLoad() and performed animation in viewDidAppear() as follows:
...ANSWER
Answered 2020-May-26 at 07:30This means the newly added sublayer doesn't get resized on layoutIfNeeded()
Layers won't resize themselves when the parent View's bound/frame change, For example: if you apply shadow or border to view and then change the frame of the view border/shadow will not update themselves automatically. You have to resize the layer in layoutSubviews
so change your code to
QUESTION
When a user clicks on a button, it randomizes the colors used to create a gradient in a large circle. Beneath it are two small circles that display the solid colors used for the gradient. They all display correctly at the start (main circle is a gradient of the randomized smaller circles' color) but when I click on the button, only the smaller circles change color; the large circle stays at the same gradient colors.
Extensions and View Controller:
...ANSWER
Answered 2020-May-23 at 06:44The gradient does not change because you add a new gradient below the existing one
QUESTION
I noticed that I have a white strip at the top of all my application pages today. I am using navigation view and I imported a third party NuGet package called Magic Gradients. I have tried to do some debugging today before posting and even after deleting each and every "part" I'm still getting this white strip on the top of all my application pages.
Heres my code
For LoginPage.xaml
...ANSWER
Answered 2020-May-15 at 03:41So for anyone who stumbles across this post looking for an answer to a similar problem, I figured out an easy way to remove the navigation bar.
You can just set HasNavigationBar
to false like so:
QUESTION
I'm running atos
to symbolicate addresses using -arch arm64 -o MyApp -s -f
. However, it prints lines like type metadata accessor for GradientView (in MyApp) (:0)
. I'd like it to print the mangled name instead, e.g. _$s22FeatureImpl12LanguageCellC19GradientViewSo012GradientI0CvpACTk
. I need this for various reasons, including to pass to an order file for the linker. Is there any way to do this with atos
?
ANSWER
Answered 2020-Apr-16 at 18:15I've found a workaround without atos
. I can use the private CoreSymbolication framework directly:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install GradientView
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page