【问题标题】:UIImage on UIButton is blurryUIButton 上的 UIImage 模糊
【发布时间】: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


    【解决方案1】:

    从我阅读的内容来看,我认为您可能会将 50 像素与 50 点混淆。 帧一般都是用点来衡量的,不是用像素来衡量的,可以看出区别HERE

    因此,基本上,如果您使用 50 点高的帧,在具有视网膜屏幕的设备中,您将需要一个 100 像素高的图像,然后它就不应该再看起来模糊了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-24
      • 1970-01-01
      • 2013-12-13
      • 2016-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-30
      相关资源
      最近更新 更多