我有 UIView 它是通过使用垂直变换
currentView.layer.affineTransform = CATransform3DGetAffineTransform(CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 1.0, 0.0, 0.0f)));
现在我需要通过触摸将这个 UIView 从一个位置移动到另一个位置,为此我使用过
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
}
但是我无法保持转换,我们如何实现这一点?
基本上,我使用以下调用在 UIView 上添加了一些 UI 元素
-(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 < 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 ==> Top Right Corner */
currentView.layer.anchorPoint = CGPointMake(1.0f, 0.0f);
}
/* Flip The View Verticaly*/
if(flipVerticle < 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 < 0)
{
/* This needs to set as we have already done flip X */
/* Need to set anchor point ==> Bottom Right Corner */
currentView.layer.anchorPoint = CGPointMake(1.0f, 1.0f);
}
else
{
/* Need to set anchor point ==> 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 < 0 || flipVerticle < 0)
{
/* Countinue with previous anchor point */
}
else
{
/* Need to set anchor point ==> Top Left Corner */
currentView.layer.anchorPoint = CGPointMake(0.0f, 0.0f);
}
}
/* Set Origins of View */
currentView.layer.position = CGPointMake(xOrigin, yOrigin);
[self addSubview:currentView];
}
}
现在我正在寻找移动这些添加的具有变换的 UIView。