我有一个RoundImageView
扩展UIImageView
与以下功能,使其成为圆形:
-(void) makeImageViewRounded {
//set the look of the image
self.layer.backgroundColor=[[UIColor blackColor] CGColor];
//self.layer.cornerRadius= self.frame.size.height /2;
self.clipsToBounds = YES;
self.layer.masksToBounds = YES;
self.layer.borderWidth=1.0;
self.layer.borderColor=[[UIColor grayColor] CGColor];
}
如何在边框和实际图像(填充)之间创建边距?我想暴露在self.layer.backgroundColor=[[UIColor blackColor] CGColor];
中设置的颜色
让yourImageView
为100 * 100,填充= 10.然后将图像调整为80 * 80并设置此图像。
并将UIImageView
的contentMode
财产设为AspectFit
创建一个比你的UIImageView更大的UIView并拥有Border。然后将ImageView放在其中心。