Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7948651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:47:02+00:00 2026-06-04T01:47:02+00:00

I have multiple UIImageView’s within a UIView . These UIImageViews have been transformed. When

  • 0

I have multiple UIImageView's within a UIView. These UIImageViews have been transformed.

When the gesture is applied to any one of the UIImageView's the overlapping imageViews should get displaced in such a way that the move outside the UIImageView's frame and we get a full view of the image (all of this would be done in an animating manner).

Also please note that the images will have been transformed so I wont be able to use the frame properties.

Right now I’m using CGRectIntersectsRect but its not giving me the desired effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:47:04+00:00Added an answer on June 4, 2026 at 1:47 am

    After struggling a lot, finally i achieved the desired result with this algorithm.

    • I calculate the list of overlapping UIImageView's and store it in an array.
      I am using CGRectIntersectsRect for this.

      Note : This will also include the UIImageView on which the gesture was applied (say target ImageView).

    • For each of these overlapping UIImageView, i perform the following steps :

      1) Calculate the angle between the overlapping ImageView and target
      ImageView. This will give me the direction to shift the Overlapping ImageView.

      2) Now shift the overlapping ImageView by some constant distance(say len), such that it maintains the same angle. Direction should be such that it moves away from the target ImageView.

      3) You can calculate the new x,y co-ordinates using Sin/Cos functions.

      x = start_x + len * cos(angle);
      y = start_y + len * sin(angle);

      NOTE: For ImageViews whose center is less than your target ImageView’s center, you will need to subtract the value.

      4) Now shift the overlapping ImageView to the new calculated center.

      5) Continue shifting it until the views do not intersect any more.

    • I am attaching my code. I hope it helps.

      -(void)moveImage:(UIImageView *)viewToMove fromView:(UIImageView
      *)imageToSendBack
      {

              CGFloat angle = angleBetweenLines(viewToMove.center, imageToSendBack.center);
      
              CGFloat extraSpace = 50;
      
              CGRect oldBounds = viewToMove.bounds;
              CGPoint oldCenter = viewToMove.center;
      
              CGPoint shiftedCenter;
      
              while(CGRectIntersectsRect(viewToMove.frame,imageToSendBack.frame))
              {
                   CGPoint startPoint = viewToMove.center;
      
                  shiftedCenter.x = startPoint.x - (extraSpace * cos(angle));
      
                  if(imageToSendBack.center.y < viewToMove.center.y)
                      shiftedCenter.y = startPoint.y + extraSpace * sin(angle);
                  else
                      shiftedCenter.y = startPoint.y - extraSpace * sin(angle);
      
      
                  viewToMove.center = shiftedCenter;
      
              }
              viewToMove.bounds = oldBounds;
              viewToMove.center = oldCenter;
      
              [self moveImageAnimationBegin:viewToMove toNewCenter:shiftedCenter];
          }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIScrollView which contains multiple UIImageViews. I want to know which UIImageView
I have a UIView and i have multiple UIImageView's as its subview. I have
I have a for loop that creates multiple UIImageViews that I add to self.view
We have multiple log files like database log, weblog, quartzlog in our application. Any
I have multiple DIVs containing an image in each. When I rollover these DIVs,
I'm trying to have multiple UIImageView 's each with two buttons - A Take
I am designing an application where a user places multiple UIImageViews one over another.
I have multiple elements with the same class clickable, i'm binding all these classes
I have a single image that needs to be placed on multiple UIImageView. I
I have multiple UIView animations running in my app. They are very short, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.