如何检测 UIImageView 何时垂直翻转 [英] How to detect when UIImageView flip vertically

查看:35
本文介绍了如何检测 UIImageView 何时垂直翻转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 UIImageView 的 scaleY 进行检查,但它不起作用(请参阅下面的代码).

I check from UIImageView's scaleY but it doesn't work (see the code below).

CGAffineTransform t = [myImageView transform]; // Keep matrix value of UIImageView
float scaleY1 = sqrt(t.b * t.b + t.d * t.d);   // 1.0000
CGAffineTransform t2 = CGAffineTransformScale(t, 1, -1.0); // flip UIImageView vertically
float scaleY2 = sqrt(t2.b * t2.b + t2.d * t2.d); // 1.0000
[myImageView setTransform:t2];
NSLog(@"1: %f, 2: %f", scaleY1, scaleY2); // 1: 1.0000, 2: 1.0000

从上面可以看出,在我们翻转 UIImageView 前后,我们得到了相同的scaleY 值".

From above, you can see that before and after we flip the UIImageView, we got the same "scaleY value".

我们应该检查的值是多少?(为了检测 UIImageView 何时垂直翻转)

What is the value that we should check? (in order to detect when UIImageView flip vertically)

推荐答案

jay gajjar 的回答很好.

The answer of jay gajjar is fine.

但是如果你不想动画然后使用

But if you dont want to animate then use

[UIView transitionWithView: flipTile
                  duration: 0.0
                   options: UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                    flipTile.image = newTileImage;
                }
                completion:^(BOOL finished) {
                    /*
                        code after completion
                    */
                }
 ];

这篇关于如何检测 UIImageView 何时垂直翻转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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