I'm trying to make a UIImageView with an angular angle and a white border, I have subclassed UIImageView, this is the code:
MyUIImageView.h
@interface MyUIImageView : UIImageView
@end
MyUIImageView.m
@implementation MyUIImageView
-(void)layoutSubviews
{
self.layer.cornerRadius = CGRectGetWidth(self.frame)/2.f;
self.layer.borderColor = [[UIColor whiteColor] CGColor];
self.layer.borderWidth = kLineWidth;
self.layer.masksToBounds = YES;
self.clipsToBounds = YES;
self.contentMode = UIViewContentModeScaleAspectFill;
self.backgroundColor = [UIColor colorWithRed:0.82 green:0.82 blue:0.83 alpha:1];
}
@end
this is the result:

seems fine, but there is a problem, as you can see here:

the image comes out of the edge of the borders, how can I avoid this problem? How can I crop the image exactly on the edge of the border?
Piero source
share