按钮更改捕捉的触摸方向。 IOS
问题描述:
我不得不用几个按钮来制作动画,看起来像是从下面旋转到屏幕上并设法做到这一点。为了解决工作,我需要改变按钮的方向上viewDidLoad中是这样的:按钮更改捕捉的触摸方向。 IOS
for (UIButton* button in self.shareButtons) {
button.imageView.image = [UIImage imageWithCGImage:button.imageView.image.CGImage
scale:1.0 orientation: UIImageOrientationDownMirrored];
}
这一切工作正常,但是当触摸一个按钮,内抓它,然后取消该方向的变化和按钮“downmirrored “由动画引起的。
如何防止/避免它?
在此先感谢。
答
尝试设置图像这样
[button setImage:[UIImage imageWithCGImage:button.imageView.image.CGImage
scale:1.0 orientation: UIImageOrientationDownMirrored]
forState:UIControlStateNormal];
也看看我的其他answer用于旋转图像
在评论应用变换提到的也是一个不错的选择
button.transform = CGAffineTransformMakeRotation((180 * M_PI)/180);
将旋转180度的UIButton。
+0
它工作正常。谢谢! – anks 2013-05-08 09:02:06
为什么你认为你需要改变图像的方向?你为什么不用(仿射)变换来做这件事? – Wain 2013-05-07 15:18:48