Leaping image just before Constraint animation - ios

I'm using Constraints within my app and have have a reasonable level of success so far; everything visual object in the gif below is Constrained.
The issue is that when selected, tiles leap to another location before animating to the final, correct destination.
From a code perspective, on a tile click, higher priority positioning Constraints are applied to the tile, the tile is added as a subview to the blue area, then animation is performed.
Can anyone shed a little light on what's happening here?
Thanks

Based on the behavior I'm seeing in your gif, I would guess that when you move the tile views between superviews (the blue area vs. the larger white area), the view jumps to it's current frame position (within the coordinate system of the old superview), but now in the coordinate system of the new superview.
The solution, I think, would be to translate the final position in the new superview to a position in the current superview, perform the animation, and only when the animation completes would you move the view to it's new superview.
Does that make sense?

Related

Flip around superview's center in iOS (RTL languages)?

I want to flip the whole view to support right to left languages. The problem is my project doesn't use autolayout so I need to perform this flip manually.
In the same time I can't simply flip the parent view because it mirror all the labels and make them unreadable. So I need to flip parent view and some of its subviews. And in the same time I can't flip these subviews because by default they are flipped around their own centers and break the layout.
How to solve this issue?

How to implement scaling by dragging view edges/corners like Apply Official Photos app crop control?

The apple official photos application have a edit function which you can crop photos. I would like to implement a similar control for cropping photos. I would like to know how to implement the resizing of the crop mask.
The resizing of the crop mask have the following requirements.
The crop mask can only be resizing by dragging edges or corners.
The anchor point of scaling is opposite the the start edge or corner.
The crop mask can have aspect ratio lock.
The crop mask should not go belong a restricted bounds.
I have done the first 3 requirements, but the 4 requirement is troubling me. Consider a case where the crop mask is at its minimal size at the restricted bounds box bottom left corner. Dragging the top edges will make the view scale with anchor point at the bottom left corner. With this strange behaviour, I think my implementation of changing bounds with opposite anchor point cannot have this behaviour. So I think the apple implementation is different from mine. And I would like to know how these behaviour can be achieved.
The question is what procedure have you even taken.
I would suggest this is done with a simple UIScrollView. Your "crop mask" can be the scroll view which may be resized and repositioned by dragging the corners of it. The scroll view must have the "clip subviews" disabled so you may see the content view outside the scroll view (the content view being the actual image).
So this procedure will already save you all the trouble with bounds when scrolling the image. Moving the scroll view will still have a bit of work... Depending on which corner you are dragging you might need to modify the content offset as you seem to have already figured and should give no trouble at all. Then what is left is putting the image into the crop mask when it gets out of bounds which should be done by calling scroll rect to visible for the whole content view frame; if not it can be easily computed manually as well.
You must also override the hit test method so that the scrolling will happen outside the scroll view.

UIView CGAffineTransform scale issue (autolayout issue?)

I am trying to apply a simple CGAffineTransform to an imageView by scaling to 0, but for some reason the frame of the imageView is getting screwed up just before the animation starts. It appears as though autolayout is applying to the shrunken view. I don't want that at all. I want the view to remain "relatively" where it was and just visually shrink to its center, but because the view is tied to the top and right of its containing view, it is being moved.
What I want is for it to shrink into its center and disappear, but just before it starts, the frame of the imageView is jumping to the top-right of its container (it seems as though iOS is calculating its size after the animation and using that to reposition it before the animation starts). After it jumps there, the animation works properly with respect to itself, with the view shrinking relative to its center, but I want to avoid it moving in the first place.
This is all taking place inside a UITableViewCell that is managed by autolayout, so I'm guessing this has something to do with autolayout and <understatement> would not be the first time autolayout has gotten in my way </understatement>.
Is there any way to prevent autolayout from affecting the transform?

ios - scrollview zooming when scrolling to end, like Fancy

I don't know what this effect is called. Fancy uses it in its app. It works like this.
You have an image at the top of a scrollview.
Drag down and the image gets zoomed to fill the extra top space, so its top edge always remains at the top edge of this scrollview
release your finger and it bounces back
Please give me some idea on how to build this effect. Thanks!
There are many open source implementations of this, such as:
https://github.com/apping/APParallaxHeader
https://github.com/modocache/MDCParallaxView
https://github.com/quemb/QMBParallaxScrollViewController
The basic idea behind these is to have an imageview as a subview of the scrollview. When scrolling, you monitor the content offset of the scrollview, and when you reach a certain threshold, you start increasing the image view's height. If you set the image view's contentMode to UIViewContentModeScaleAspectFill, you will get the effect you want.

iOS - Positioning of a running animation on orientation change

I have applied a CABasicAnimation to a layer. The animation modifies the "position.y" layer property to create a gentle bouncing effect; it is set to autoreverse and repeat.
I use the From and To values to position the animation in the bottom right quadrant of the screen. It works quite nicely until I change the orientation of the device. The problem is the animation is positioned relative to the top of the screen. So when the orientation changes it is no longer positioned in the correct place.
The autoresizingMask for the View itself is correctly set in interface builder, but the animation doesn't seem to take any notice of that. I guess because the animation is assigning an absolute value to the layers position.
I'm a bit stumped, thanks in advance.
Can you place your animation in a seperate view so it is self contained and then adjust that view with the rotation?

Resources