【发布时间】:2014-11-29 23:14:19
【问题描述】:
我一直在与这个问题作斗争,我想在 UIButton 上显示一个 png,但由于某种原因,图像最终在模拟器和物理设备上都非常模糊。我尝试使用所有不同大小的图像,全部为 326 ppi(在 xcode 中验证),但没有一个看起来是正确的。我也尝试使用 UIGraphics 在我的应用程序中调整图像大小,但问题仍然存在。这是设置按钮的代码:
//MIRROR BUTTON
_mirrorButton = [UIButton buttonWithType:UIButtonTypeCustom];
//_mirrorButton.frame = CGRectMake(buttonWidth, 0.0f, buttonWidth, buttonHeight);
_mirrorButton.frame = CGRectMake(64, 0, 64, 50);
UIImage *mirrorImage;
_mirrorButton.backgroundColor = [MessageView getUserColor];
mirrorImage = [UIImage imageNamed:@"mirror.png"];
[_mirrorButton setImage:mirrorImage forState:UIControlStateNormal];
[_mirrorButton addTarget:self action:@selector(mirrorPressed) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_mirrorButton];
UIButton 和图像的高度都应该是 50 像素。我的 UIButton 的框架是完整的,图像甚至具有均匀的像素宽度和高度(有人说这有助于居中)。任何煽动将不胜感激。谢谢。
【问题讨论】:
标签: ios uibutton uiimage blurry