I am trying to put a shadow around a thumbnail image on at tableview cell. However, when I do it, it doesn’t render correctly as the screenshot below shows:
http://imageshack.us/photo/my-images/27/iossimulatorscreenshot7r.png/
(sorry cant embed screenshots as a new user!)
On another tableview in the app, the same code works perfectly as shown:
http://imageshack.us/photo/my-images/4/iossimulatorscreenshot7.png/
The code I am using is exactly the same for both:
ImageView.image = [UIImage imageNamed:image];
ImageView.layer.borderColor = [UIColor blackColor].CGColor;
ImageView.layer.borderWidth = 1;
The problem occurs when I try to put a shadow on the tableview too:
imageshack.us/content_round.php?page=done&l=img577/1947/iossimulatorscreenshot7.png
Any ideas?
I set up mostly everything using Storyboards, so maybe its somethings to do with that?
(from my original comment) First image looking like you’ve bordered the
UITableViewCellobject and not theUIImageViewobject inside the cell.It does explain it.
Your
UIImageViewis not actually your image view, it’s a reference to the wholeUITableViewCellwhich is why the border draws around the whole cell, not just the image. Since the border methods you call work on allUIViewand bothUITableViewCellandUIImageViewhappen to be sub-classes ofUIViewyour app doesn’t crash.The question is… why are they wrong. How are you assigning your
ImageViewvariable? Is it done in code or an IBOutlet? If it’s an IBOutlet, check the “Connections Inspector” on your view controller and make sure you didn’t accidentally hook the cell up instead of the image (this is my guess). If you did it in code, we’ll probably need to see the code.Side note: Convention says variable names should start with lowercase letters. Class names should start with uppercase letters. So
UIImageView *imageView;