Mar*_*yer 5 transform core-graphics rotation xamarin.ios cgaffinetransform
我定义了一个UIControl,在其中使用MonoTouch.CoreGraphics类在其中绘制了一些项目,并已通过AddSubview将UIControl放入UIView中。我正在尝试查看并旋转整个过程,以模拟某种类似于分针或秒针在时钟或表盘上的运动。我的印象是,我可以使用UIView上的Transform来做到这一点。
我的UIView的名称是容器。我试过了:
container.Transform.Rotate(-0.78f);
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
CGAffineTransform t = CGAffineTransform.MakeIdentity();
t.Rotate(-0.78f);
container.Transform = t;
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
CGAffineTransform t = CGAffineTransform.MakeRotation(-0.78f);
container.Transform = t;
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个和它的其他组合:
UIView.BeginAnimations("rotate");
UIView.SetAnimationDuration(0.5);
container.Transform.Rotate((float)Math.PI);
UIView.CommitAnimations();
Run Code Online (Sandbox Code Playgroud)
以上都不对我的显示器有任何影响。丝毫不会旋转或移动。所有与iOS相关的帖子都引用了CGAffineTransformRotate,但我找不到与之完全匹配的Mono,并假设这与我在上面所做的等同。我还有其他方法可以尝试使视图旋转吗?
您走在正确的轨道上。我正在开发一个大型游戏,并在我的代码中到处进行。这是我能给您的最简单的例子:
using MonoTouch.CoreGraphics;
float degrees = 15;
UIView aView = new UIView(new RectangleF(10,10,10,10));
aView.Transform = CGAffineTransform.MakeRotation(3.14159f * degrees / 180f);
Run Code Online (Sandbox Code Playgroud)
而已。
示例很少,特别是MakeRotation函数以弧度为单位(因此使用pi转换为度)。
归档时间: |
|
查看次数: |
4768 次 |
最近记录: |