And how can I draw with the draw button huh huhhwjrjirjkhkjewkjhhhhhhhhhhhhhhhhhhhhqgyldj13t5uiqqqqqetyriuo5hfsijoeutygjof;suyetldg8usyetfihus8ygggt8;wyiodjthghiugklvjciofgutkyilgofut
Related
Is there a way in iOS to run a fade animation on a UIView (UILabel specifically) that will fade in with a swipe action (so if it paused half way, the left side is visible, right side invisible and middle some gradient between).
I'm wondering if theres a Gradient mask I could use with the Alpha channel?
Any ideas or code snippets for achieving this sort of reveal? Vertical or Horizontal.
(Link to the same question but for Android for reference - Android - How to fade in a View with a horizontal swipe/fade?)
Simple hacky solution will be with additional view which can be placed on top of the label. The way that you can do it is to create this view and to animate it is movement by X axis or Y axis. Still you will need to do two things
Simple swipe gesture which will trigger the animation.
Pan Gesture which will move the view with movement of the gesture.(Maybe if you drag more than 50% of the label width/height to trigger the rest of the animation.)
Animation will be better if you add gradient from clear colour to the background colour.
Maybe is not the exact answer of your question but it will work good enough.
As addition you can track your pan gesture like this
#objc private func didPan(_ sender: UIPanGestureRecognizer) {
switch sender.state {
case .began:
//dispalay view
case .changed:
let translation = sender.translation(in: view)
//move view by x or y
case .ended,
.cancelled:
//finish animation or reverted
}
default:
break
}
}
You should have such views
Parent view - this view will clip subview in his bounds
Label - this is your label and it is in the parent
Animation view - it is in the parent and it is outside of it is bounds in the beginning of the animation.
I need to know is there any function to fill the masked corners. I have tried CAShapelayer still, it is overlapping with the outside view. So, I need to fill it perfectly without showing the background color.
The below image shows the corners are occupied with pink color. But I need those colors to match with white.
Just apply the corner radius
view.layer.cornerRadius = 9.0
view.backgroundColor = UIColor.red.cgColor
Result:
The middle image with the alert box popup is the result I want to achieve.
When popup an alert box, everything changes to black and white. The way to achieve this in design is to adding a layer on top with background colour black and blending mode hue.
So in order to implement this, here is what I tried.
I tried to add a view on top (Transparent background). Inside that view, I draw a rectangle with blend mode hue.
override func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
UIColor.black.setFill()
context?.setBlendMode(.hue)
let rect = rect
context?.addRect(rect)
context?.drawPath(using: .fillStroke)
}
The UIView has constraint to set to full screen. However that just result a black rectangle.
Any hint on how to achieve this?
There is no such thing as a blend mode with what is behind the view. Blend mode is about drawing into this context.
To achieve what you're describing, you would have to take a snapshot of the current view controller's view and draw it in black-and-white into your context.
The usual thing, however, is just to set the tintAdjustmentMode. That is what a real alert view does.
I have a UILabel added as a subview in a UIViewController.
I am adding subview (overlay view) view on UIViewController.view.
How to make a transparent circle in overlay view so that the UILabel is visible from transparent circle.
What I am able to do for now:
I am able to create a transparent circle with hardcoded coordinates.What I want is that I just pass UILabel and get a overlay with transparent circle around UILabel.
Any thoughts.
My source code here
I want to tap to zoom a UIImageView and put it inside a overlay.
Just like this picture.I want to put the cyan color rect to the blue one.How can I do this?
You can use multiple CALayers. CALayer can be overlaid easily, as you can stack sublayers