OGeek|极客世界-中国程序员成长平台

标题: ios - 在横向模式下应用转换/旋转后获取 ImageView 的精确帧 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:29
标题: ios - 在横向模式下应用转换/旋转后获取 ImageView 的精确帧

我正在开发一个应用程序,当设备以横向模式旋转时,我刚刚将转换分配给 ImageView 。现在我想要应用转换后该 ImageView 的精确框架。我试过这个例子:Find Frame Coordinates After UIView Transform is Applied (CGAffineTransform)但没有成功。我用过的代码:

UIView *Newview = [[UIView alloc] initWithFrame:_FullImageView.frame];
_FullImageView.transform=CGAffineTransformMakeRotation(-M_PI_2);

_FullImageView.frame = CGRectMake(Newview.frame.origin.x, Newview.frame.origin.y,Newview.frame.size.width,Newview.frame.size.height);

_FullImageView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin |  UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;

如果有人有任何建议,请告诉我。将不胜感激。谢谢。



Best Answer-推荐答案


请检查以下代码。希望你也需要。

UIView*Newview = [[UIView alloc] initWithFrame:_FullImageView.frame];

_FullImageView.transform=CGAffineTransformMakeRotation(-M_PI_2);

CGRect rect = _FullImageView.frame;

检查 rect frame ,它会为您提供变换后的框架。

关于ios - 在横向模式下应用转换/旋转后获取 ImageView 的精确帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45605081/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4