Question

I use auto layout and building app for iOS 7. I am using a custom UITableViewCell. I want to display an UIImageView inside it with some margin from contentView's borders. So I have taken an UIView which has margin from contentView's borders. UIImageView that I want to display is put into this UIView with all edges touching its superview.

Now, issue is the UIImage (green background) which is set to UIImageView is not displayed perfectly. By perfectly I mean that it is displayed but bottom 1px is not displayed. I have set image in storyboard and it looks perfect there as shown below.

enter image description here

But when I run the app then it looks as shown below. Concentrate on bottom black line which is clearly visible in storyboard but not when I run the app.

enter image description here

Please note that cell height in storyboard is 95pts. Image height is 77pts (non-retina). Also when I scroll cell up and down then I see that during scrolling this bottom line is visible, but that time top lines is not properly visible.

Was it helpful?

Solution

I have noticed such sub-pixelization issues when the simulator is in less than 100% scale size.
Especially on scrolling, when you notice it's sharpness fluctuates, it basically indicates that it's not being rendered properly.

So, test this scenario in the iOS simulator in 100% scale size

  • command+1
    or...
  • simulator menu > window > scale > 100%.

Alternatively, test this scenario on a device as well since it'll be more "realistic".

If the issue persists then give even numbers in the frame size and/or avoid float values *(but don't quote me on this)

OTHER TIPS

I had the same issue with autolayout and CustomCell with a specific image.

What I did was ticking clip subviews, and the problem was gone. You can tick it in IB by checking imageView and go to Attributes Inspector:

Clip Subviews

Considering that your autolayout is correct, this question may help.

But anyways give it a try and give me feedback

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top