ios - 从特定一侧旋转 UIImageView - iOS

标签 ios iphone objective-c uiimageview rotation

我想从特定的一侧(例如右侧)旋转图像 (UIImageView)。

我知道:-

float degrees = 20; //the value in degrees
imageView.transform = CGAffineTransformMakeRotation(degrees * M_PI/180);

但它从中心旋转。

我想从一个特定的一侧旋转我的 UIImageView(即左侧将在其位置,右侧将改变其位置)。

提前致谢。

最佳答案

尝试使用anchorPoint属性。

imageView.layer.anchorPoint = CGPointMake(0, 0);//Top left angle
float degrees = 20; //the value in degrees
imageView.transform = CGAffineTransformMakeRotation(degrees * M_PI/180);

不要忘记添加 QuartzCore 框架。

关于ios - 从特定一侧旋转 UIImageView - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20785839/

相关文章:

ios - 在 appDelegate 中访问 Storyboard 和嵌套的 UIViewController

iphone - ASIHTTPRequest 仅在我对字符串进行硬编码时有效

iphone - 如何以编程方式在 Objective C 中创建浮雕按钮?

iphone - 无法将分段控件连接到其 IBOutlet

ios - Mac 应用程序的 Xcode 11 Firebase 身份验证出现错误访问钥匙串(keychain)时发生错误

ios - UITableViewCell 覆盖向左滑动的删除按钮

iphone - NSDateComponents 返回奇怪的时间

iOS - 解析使用 UTF8Encoding 创建并作为 C 字符串发送的 JSON 时出错

ios - 解包可选值时发现 nil

ios - 屏幕左/左下角的 UINavigationController 和触摸事件