Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Move UIView using touchesMoved having affineTransform
    text
    copied!<p>I have UIView which is transform vertically by using</p> <pre><code>currentView.layer.affineTransform = CATransform3DGetAffineTransform(CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 1.0, 0.0, 0.0f))); </code></pre> <p>Now I need to move this UIView from one location to other by using touches, for this I have used</p> <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { } -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { } </code></pre> <p>But I am not able to maintain the transform, How we can achive this?</p> <p>Basically I have added some UI elements on UIView using following call</p> <pre><code>-(void)AddItemOnView:(UIView*)aView Angle:(CGFloat)aDegree XOrigin:(CGFloat)aXOrigin YOrigin:(CGFloat)aYOrigin Width:(CGFloat)aWidth Height:(CGFloat)aHeight FlipX:(CGFloat)aFlipHorrizontal FlipY:(CGFloat)aFlipVerticle { UIView* currentView = aView; if(currentView) { CGFloat angle = aDegree; CGFloat flipHorrizontal = aFlipHorrizontal; CGFloat flipVerticle = aFlipVerticle; CGFloat xOrigin = aXOrigin; CGFloat yOrigin = aYOrigin; CGFloat width = aWidth; CGFloat height = aHeight; currentView.layer.anchorPoint = CGPointMake(0.0f, 0.0f); currentView.frame = CGRectIntegral(CGRectMake(0, 0, width, height)); /* Flip The View Horrizontly*/ if(flipHorrizontal &lt; 0) { /* Concat With previous Layer Operation */ currentView.layer.affineTransform = CATransform3DGetAffineTransform(CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0f))); /* Need to set anchor point ==&gt; Top Right Corner */ currentView.layer.anchorPoint = CGPointMake(1.0f, 0.0f); } /* Flip The View Verticaly*/ if(flipVerticle &lt; 0) { /* Concat With previous Layer Operation */ currentView.layer.affineTransform = CATransform3DGetAffineTransform(CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 1.0, 0.0, 0.0f))); if(flipHorrizontal &lt; 0) { /* This needs to set as we have already done flip X */ /* Need to set anchor point ==&gt; Bottom Right Corner */ currentView.layer.anchorPoint = CGPointMake(1.0f, 1.0f); } else { /* Need to set anchor point ==&gt; Bottom Left Corner */ currentView.layer.anchorPoint = CGPointMake(0.0f, 1.0f); } } /* Perform Rotation */ if(angle != 0) { /* Concat With previous Layer Operation */ currentView.layer.affineTransform = CATransform3DGetAffineTransform(CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(DegreesToRadians(angle), 0, 0, 1.0))); if(flipHorrizontal &lt; 0 || flipVerticle &lt; 0) { /* Countinue with previous anchor point */ } else { /* Need to set anchor point ==&gt; Top Left Corner */ currentView.layer.anchorPoint = CGPointMake(0.0f, 0.0f); } } /* Set Origins of View */ currentView.layer.position = CGPointMake(xOrigin, yOrigin); [self addSubview:currentView]; } } </code></pre> <p>Now I am looking to Move these added UIViews having transform.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload