ios - UIButton 的imageView 改变transform属性使图片旋转45度时,图片消失了?
PHPz
PHPz 2017-04-18 09:48:22
0
1
1229

普通的UIImageView通过设置transform旋转都是正常的,但是UIButton的中的imageView表现十分奇怪。

旋转图片代码如下:(self 是继承自UIButton类的一个实例)

    [UIView beginAnimations:@"rotation1" context:nil];
    [UIView setAnimationDuration:1];
    self.imageView.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(M_PI_4));
    [UIView commitAnimations];
    

图片直接消失,旋转度数不为45度时,图片不会消失,但是好像旋转的平面并不是当前屏幕所在平面。
我理解的transform应该是在当前视图屏幕做平移、旋转、放缩操作,但是现在的现象很奇怪。难道系统有对这个imageView做什么特殊处理?

有没有大神解答一下为什么会这样?

PHPz
PHPz

学习是最好的投资!

reply all(1)
黄舟

Rotate 45 degrees and pass it directly to M_PI_4, which represents radians without conversion. I just tested it, and it will be displayed when rotated 45°, but the shape is weird. I don't particularly understand the reason for this, but directly rotating the button can achieve the effect you want.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!