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

  • SEARCH
  • Home
  • 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 6775767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:56:46+00:00 2026-05-26T15:56:46+00:00

transform a square image or round image is easy to do… But what if

  • 0

transform a square image or round image is easy to do…

But what if a rectangle image ???

This is the image I want to transform with touch event .

enter image description here

The circle center is (30 , 236) , if I touch any place on the screen

Imageview will transform the arrow to my touch point.

But the circle center still the same place .

I try to transform the image use a test angle

It will become like this …

enter image description here

How to adjust the image ?

Also the code is here

- (void)viewDidLoad {
    CGRect arrowImageRect = CGRectMake(20.0f, 20.0f, 15.0f, 220.0f);
    arrow = [[UIImageView alloc] initWithFrame:arrowImageRect];
    [arrow setImage:[UIImage imageNamed:@"arrow.png"]];
    arrow.opaque = YES;
    [self.view addSubview:arrow];
    [super viewDidLoad];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self.view];
    NSLog(@"Position X: %f \n, Y: %f",touchPoint.x,touchPoint.y);
    CGAffineTransform transform = CGAffineTransformIdentity;
    arrow.transform = CGAffineTransformRotate(transform, ?????? );
}

The ?????? part should be the last solution …

Or Maybe I need to resize the imageview ???

Thanks for any reply or answer 🙂

Webber

  • 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-05-26T15:56:46+00:00Added an answer on May 26, 2026 at 3:56 pm

    Here is the final solution I figure this problem

    check this code

    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch=[[event allTouches]anyObject];
    
        [self transformSpinnerwithTouches:touch];
    }
    
    -(void)transformSpinnerwithTouches:(UITouch *)touchLocation
    {
        CGPoint touchLocationpoint = [touchLocation locationInView:self.view];
        CGPoint PrevioustouchLocationpoint = [touchLocation previousLocationInView:self.view];
        //origin is the respective piont from that i gonna measure the angle of the current position with respective to previous position ....
        CGPoint origin;
        origin.x = arrow.center.x;
        origin.y = arrow.center.y;
        CGPoint previousDifference = [self vectorFromPoint:origin toPoint:PrevioustouchLocationpoint];
        CGAffineTransform newTransform = CGAffineTransformScale(arrow.transform, 1, 1);
        CGFloat previousRotation = atan2(previousDifference.y, previousDifference.x);
        CGPoint currentDifference = [self vectorFromPoint:origin toPoint:touchLocationpoint];
        CGFloat currentRotation = atan2(currentDifference.y, currentDifference.x);
        CGFloat newAngle = currentRotation- previousRotation;
        temp1 = temp1 + newAngle;
        //NSLog(@"temp1 is %f",temp1);
        //NSLog(@"Angle:%F\n",(temp1*180)/M_PI);
        newTransform = CGAffineTransformRotate(newTransform, newAngle);
        [self animateView:arrow toPosition:newTransform];
    }
    -(void)animateView:(UIView *)theView toPosition:(CGAffineTransform) newTransform
    {
    arrow.transform = newTransform;
    }
    
    -(CGPoint)vectorFromPoint:(CGPoint)firstPoint toPoint:(CGPoint)secondPoint
    {
        CGFloat x = secondPoint.x - firstPoint.x;
        CGFloat y = secondPoint.y - firstPoint.y;
        CGPoint result = CGPointMake(x, y);
        //NSLog(@"%f %f",x,y);
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to transform an XML document. The source XML looks like this: <svc:ElementList>
I want to transform /foo/bar/.. to /foo Is there a bash command which does
How can I transform jQuery carousel to show 3x3 square of images instead of
I want to implement a simple SceneGraph in Haskell using Data.Tree consisting of Transform
I'm animating an UIImage view with this code CABasicAnimation *animation; animation = [CABasicAnimation animationWithKeyPath:@transform.rotation];
I want to transform in Java: dd fdas dd fdas fads f das fdasf
I'm trying to transform a table to an XML struture and I want one
Normally, square matrices are used to transform various points. You have a 4D vector
Create a square UIView object testView_, and add this at viewDidLoad: - (void)viewDidLoad {
I'm not sure if this is possible, but I thought it would be cool

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.