为什么UIBarButtonItem图像总是模糊/模糊/像素化

时间:2014-09-15 17:37:19

标签: xcode swift uibutton uibarbuttonitem uinavigationitem

这是我目前的代码:

var reply = UIBarButtonItem(image: UIImage(named: "reply"), style: UIBarButtonItemStyle.Plain, target: self, action: Selector("reply:"))
self.navigationItem.rightBarButtonItem = reply

img右上角的按钮始终是模糊的。这是来自iPhone4s设备的截图,因此它不是与视网膜相关的问题。

我尝试过不同的图像尺寸,范围从30x30到512x512,并使用customView添加图像。这些方法没有解决问题。

提前致谢。

3 个答案:

答案 0 :(得分:9)

我用这种方法解决了它:

var replyBtn = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
replyBtn.setImage(UIImage(named: "reply"), forState: UIControlState.Normal)
replyBtn.addTarget(self.navigationController, action: Selector("reply:"), forControlEvents:  UIControlEvents.TouchUpInside)
var item = UIBarButtonItem(customView: replyBtn)
self.navigationItem.rightBarButtonItem = item

使用完全相同的图像显示非常清晰的按钮。

答案 1 :(得分:3)

从IOS人机界面指南中,图标应为22x22 看一下这里的文档: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/BarIcons.html

答案 2 :(得分:0)

尝试一下:

SELECT concert.*FROM concert JOIN event e ON concert.id=e.event_id WHERE TIMESTAMPDIFF(MINUTE,e.begin,e.end)>=?AND TIMESTAMPDIFF(MINUTE,e.begin,e.end)<=?AND name like GROUP BY concert.id