1

I've encountered an issue in UIImageView: If you round the corners of the imageView and then add a border, part of the image (+- 1 pixel) lies outside the edge of the border. See below image. enter image description here

Is this a bug, or am I doing something wrong? Here is my code:

- (void)viewDidLoad {
    [super viewDidLoad];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(50.0, 50.0, 100.0, 100.0)];
    imageView.image = [UIImage imageNamed:@"grey.png"];
    imageView.layer.masksToBounds = YES;
    imageView.layer.cornerRadius = 50.0;
    imageView.layer.borderColor = [UIColor greenColor].CGColor;
    imageView.layer.borderWidth = 2.0;
    [self.view addSubview:imageView];
}

EDIT: This is a duplicate of stackoverflow.com/a/30125297/1271826 and confirms this bug. See his workaround by adding a CAShapeLayer

Lneuner
  • 1,090
  • 1
  • 9
  • 19

0 Answers0