rotate multiple UIViews around a center point with rotation gesture - iphone

I have 4 rectangular views which make up a square around the center of the screen, and I'm trying to figure out a way to spin the views around the center point of the screen when the user does a 2 finger rotation gesture. Can anyone help me figure out how to rotate 4 views around the center point of the screen instead of their own center?
Thanks...

You can use IQGeometry to easily create your complex algorithm.
IQGeometry
This framework contains all basic and some complex calculations for you.
Straight Solution to your harder approach.
1) Rotate your view by CGAffineTransformMakeRotation. Say 45 degree.
2) Now use IQGeometry+CGPoint function to calculate new center point of your view.
CGPoint CGPointRorate(CGPoint point/*CurrentCenterPoint of View*/, CGPoint basePoint/*Base Center Point around which we have to rotate*/, CGFloat angle/*Angle 45(Radian or angle try it your self)*/);
3) Set your view's center point to new centerPoint. and that's it.
4) Apply this algorithm to all your 4 views.

Related

UIPanGestureRecognizer - Avoid moving two images simultaneously - Swift

I have a ViewController with 3 UIImageView with its images. I am using Pinch, Pan and Rotate gesture on all three images. While doing Pinch or Rotation i got two finger point with opt+mouse_click. There in the finger point, if two images are pointed with each finger point, both images are moving around.
I actually don't want that move(pan) while doing opt+mouse_click, just need to rotate or zoom the images with two finger points.
Help me to resolve, Thanks in advance
You can try to limit the UIPanGestureRecognizer 's finger that touch on screen to 1 to avoid it. Rotate or zoom will need 2 fingers.
More information from Apple's doc
The maximum number of fingers that can be touching the view for this gesture to be recognized.
https://developer.apple.com/documentation/uikit/uipangesturerecognizer/1621208-maximumnumberoftouches

UIview Intersection with Wheel Type View drawn using CGContext

I Have two UIViews one is steady stationary and another is rotating wheel type.
I want to detect the intersection of the stationary view with the each arc of the Rotating wheel...so i can decide which wheel arc is intersects the stationary wheel?
please help me.....
You can use CGRectIntersectsRect(rect1,rect2)

Get objects in custom UIView objective c

I have a custom UIView which I named UIWheel that I am rotating upon TouchDown. This UIWheel has many UIViews which I would like to rotate at the opposite direction (so that they remain appearing upright even after rotation) .
How do I code to tell it to get all of the UIViews in the UIWheel and in TouchDown rotate in the opposite direction?
Using the subviews property, iterate over each subview and rotate it exactly the way you rotate the outer view, but in the opposite direction.
As another option, you can move the part which you do want to rotate into its own subview, and just rotate that subview. It's a little counter-intuitive to rotate every object, then rotate a large number of them back into position.

problem in quartz 2D drawing touches began

I have drawn 5 circles in in my app one above the other . But i want to perform different operations when i touch each circle and there is only one touches began where I can perform touches for the entire view.. can anyone help me how to do that.
Either process the coordinates of the touch to "grab" a specific circle (you know their coordinates if you have the origins and radii), or put each circle into its own view, and make five subviews/circles of a parent view. Pass the touch down the view chain until the coordinates overlap.

Flipping UIViews From Top / Bottom

I'm well aware that there are only two available UIView transitions, UIViewAnimationTransitionFlipFromLeft and UIViewAnimationTransitionFlipFromRight. I'm wondering if there is anyway that I can implement / emulate a UIViewAnimationTransitionFlipFromTop or UIViewAnimationTransitionFlipFromBottom.
The only way I can think to do this is by flipping the x axis with the y axis, but I've not seen any information about how to do this. Just setting the coordinates of each axis won't fix the issue as the x-axis till remains the x-axis.
Does anyone have any ideas how this can be accomplished?
You can do this by applying a CATransform3D to your main view's CALayer, with your secondary view's CALayer behind it. In this response, I point to a Mac implementation of this animation by Mike Lee. You should be able to reuse a significant portion of that code to recreate this effect on the iPhone.
Guess you'll have to use a UIView animation block with a 3D rotation transform of 90 degrees, have the Core Animation delegate call you when that's done, swap the view with the new one (3D rotated on the other side) and chain with the last 90 degrees for the new view...
Although its not exactly what you want, there are two built-in animations that you didn't mention: UIViewAnimationTransitionCurlDown and UIViewAnimationTransitionCurlUp.
CurlUp looks like someone is peeling the view from the bottom up to the top, and CurlDown looks like the view is being unrolled down on top of the screen from top to bottom. You should at least give them a look, as they are easy to use.