uiscrollview zoom to overlay rect - ios

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

Related

Change Everything to Black And White (Applying Blending to View Background Colour)

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.

UIImageView partial opacity

Situation
I have a UIView( light gray colored ) and a UIImageView as a subview of the view.
The Image View would move and rotate by changing its frame or using CGAffineTransform. Part or entire Image View might go beyond the parent View( the light gray one )
Problem
I need to make the ImageView opaque where it’s not over the parent view( light gray one ).
How can I achieve this?
try this view.clipsTobounds = NO;

Creating a transparent circle in overlay, around a view in superview

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

Get uiview section under uiimageview?

I have an UIView as background, and a UIImageView above it.
What I want to do is fill the UIImageView with the UIView section that is in the back (without the white border)
I tried cropping a snapshot of the background but it doesnt look good. there is always a difference.
Make the background UIView a subview of the UIImageView and then set the property of the UIImageView yourImageView.clipsToBounds = YES
Use CALayer mask. The mask will be the smaller image view, and will be assigned to the background view's mask property.

UIView border cover sub-view?

I have a UIView which includes a UIButton which is partially on UIView. I have a problem when I draw a border on my UIView. Please have a look at my screenshot:
You can see the border is above the UIButton, why? Can anybody suggest? Thanks
Thanks for aăâ, I found a solution.
Basically the border is always drawn on top of everything
What I did is:
Create a UIView with color of border
Create another UIView as the child the main UIView which is a little bit smaller than the first one. The color of this newly create UIView is the main color
Here is the code:
self.layer.cornerRadius = 15;
self.layer.masksToBounds = YES;
self.backView.layer.cornerRadius = 15;
self.backView.layer.masksToBounds = YES;
The result is:
It's more or less what I need although it's not perfect.
It could have to do with the order that the objects are drawn. In your storyboard's "Document Outline", views that are lower down in a view controller's outline are drawn later. Perhaps the button is not the last drawn view, like you want?

Resources