[英]iOS Image rotates on button press
我正在从API下载一些图像到我的ios应用程序,然后将图像显示为按钮背景。 这是代码:
NSData *imageData = [r responseData];
UIImage *image = [UIImage imageWithData:imageData];
UIBlockButton *imageView = [UIBlockButton buttonWithType:UIButtonTypeCustom];
[imageView setBackgroundImage:image forState:UIControlStateNormal];
这是奇怪的部分。 按下按钮时,垂直图像(长度小于高度)将旋转90度。 有没有人经历过这个/它是一个错误?
编辑:所以我的服务器以旋转状态发送图像。 不知何故,UIButton知道在未选中时旋转它,但在我选择它时不会进行相同的校正。
添加[imageView setBackgroundImage:image forState:UIControlStateHighlighted];
当然,除非您更喜欢突出显示状态的其他图像来模拟实际按下按钮。 在这种情况下,您将使用/中的其他图像而不是“图像”。
但至少你应该摆脱那种奇怪的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.