旋转M_PI_4后,iOS UIImageView消失

这里基本上发生的是我正在向UIBarButtonItem添加一个自定义视图,我需要将其旋转45度,如果旋转90度或180度,旋转效果会很好,但是当它小于90度时,对象会变形,并且在45deg上,对象消失了.
以下是按钮和动画的片段.
UIImageView * menuImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plus.png"]];
menuButton = [[UIBarButtonItem alloc] initWithCustomView:menuImage];
UITapGestureRecognizer * tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleMenuView:)];
[menuImage addGestureRecognizer:tap1];
[menuImage setUserInteractionEnabled:YES];
[menuImage.layer setShadowColor:[UIColor blackColor].CGColor];
[menuImage.layer setShadowOffset:CGSizeMake(ShadowSizeWidth,ShadowSizeHeight)];
[menuImage.layer setShadowOpacity:ShadowOpacity];
[menuImage.layer setShadowRadius:ShadowRadius];

[self.navigationItem setRightBarButtonItem:menuButton];

轮换:

[UIView animateWithDuration:animationRotateButtonDuration delay:0.0f options:UIViewAnimationCurveLinear animations:^{
    CGAffineTransform myTransform = CGAffineTransformMakeRotation(-M_PI_4);

    UIBarButtonItem * currentItem =  menuButton;

    currentItem.customView.transform = myTransform;

}completion:^(BOOL finished){
}];

解决方法

使用anchorPoint并导入“QuartzCore / QuartzCore.h”
currentItem.customView.layer.anchorPoint = CGPointMake(1.0,0.0);//it is not fixed point you have to change.

我认为这对你有所帮助.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...