我从UIImageView的scaleY中检查但是它不起作用(参见下面的代码)。
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值”。
我们应该检查的价值是多少? (为了检测UIImageView何时垂直翻转)
答案 0 :(得分:0)
检查imageview的transform属性怎么样?如果视图已经转换,您将看到那里。这是我看到的,如果我在转换后在控制台中打印myImageView的值:
(lldb)po myImageView
UIImageView:0x8f59f30; frame =(0 0; 0 0); transform = [1,0,-0, -1,0,0]; userInteractionEnabled = NO;
答案 1 :(得分:0)
你可以试试这个
[UIView transitionWithView: flipTile
duration: 0.5
options: UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
flipTile.image = newTileImage;
}
completion:^(BOOL finished) {
/*
code after completion
*/
}
];
答案 2 :(得分:0)
jay gajjar的答案很好。
但如果您不想动画,请使用
[UIView transitionWithView: flipTile
duration: 0.0
options: UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
flipTile.image = newTileImage;
}
completion:^(BOOL finished) {
/*
code after completion
*/
}
];