关于旋转滑块的问题 [英] Question about rotating a slider

查看:96
本文介绍了关于旋转滑块的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要在一端旋转滑块的应用程序。但是,通过使用CGAffineTransformMakeRotation(),我只能在中心旋转滑块。

I am working on an application which needs to rotate the slider at one end. However, by using CGAffineTransformMakeRotation(), I can only rotate the slider at the centre.

我应该怎么做才能在终点旋转滑块?如果可能,请提供一小段示例代码。非常感谢。

What should I do in order to rotate the slider at the end point? If possible, please give a short paragraph of sample code. Thanks a lot.

推荐答案

我通过设置<旋转 UIImageView code> anchorPoint 视图层的属性。例如

I rotate a UIImageView by setting the anchorPoint property for the view's layer. e.g.

myView.layer.anchorPoint = CGPointMake(0.5, 1.0);

然后应用 CATransform3DRotate 作为图层的 transform property

and then applying a CATransform3DRotate as the layer's transform property

CATransform3D rotationTransform = CATransform3DIdentity;
rotationTransform = CATransform3DRotate(rotationTransform, positionInRadians, 0.0, 0.0, 1.0);
myView.layer.transform = rotationTransform;

我是从Apple的节拍器示例,所以值得检查一下。希望有帮助

I found this from Apple's metronome example, so it's worth checking that out. Hope that helps

这篇关于关于旋转滑块的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆