Why is UIBarButtonItem image always fuzzy / blurry / pixelated

Here is my current code:

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


imgThe button in the upper right corner is always fuzzy. This is a screenshot from an iPhone4s device, so it is not retina related.

I've tried different image sizes from 30x30 to 512x512 and add the image using customView. These methods did not fix the problem.

Thanks in advance.


source to share

2 answers

I solved it with this method:

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


It displays a very clear button using the same image.



In the IOS human interface manual the icon should be 22x22 Take a look at the documentation here: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/BarIcons.html



All Articles