菜鸟教程小白 发表于 2022-12-11 18:29:15

ios - 在横向模式下应用转换/旋转后获取 ImageView 的精确帧


                                            <p><p>我正在开发一个应用程序,当设备以横向模式旋转时,我刚刚将转换分配给 ImageView 。现在我想要应用转换后该 ImageView 的精确框架。我试过这个例子:<a href="https://stackoverflow.com/questions/19523487/find-frame-coordinates-after-uiview-transform-is-applied-cgaffinetransform?lq=1" rel="noreferrer noopener nofollow">Find Frame Coordinates After UIView Transform is Applied (CGAffineTransform)</a>但没有成功。我用过的代码:</p>

<pre><code>UIView *Newview = [ 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;
</code></pre>

<p>如果有人有任何建议,请告诉我。将不胜感激。谢谢。 </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>请检查以下代码。希望你也需要。 </p>

<pre><code>UIView*Newview = [ initWithFrame:_FullImageView.frame];
</code></pre>

<p>_FullImageView.transform=CGAffineTransformMakeRotation(-M_PI_2);</p>

<pre><code>CGRect rect = _FullImageView.frame;
</code></pre>

<p>检查 rect frame ,它会为您提供变换后的框架。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在横向模式下应用转换/旋转后获取 ImageView 的精确帧,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/45605081/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/45605081/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在横向模式下应用转换/旋转后获取 ImageView 的精确帧