UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100,100,100,100)];
view.backgroundColor = [UIColor redColor];
view.layer.borderWidth = 1.0;
view.layer.borderColor = [UIColor blueColor].CGColor;
UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(-8, -10, 20, 20)];
image.image = [UIImage imageNamed:@"sample"];
[view addSubview:image];
图像在 View 上,但边界线是透明的・・・ 请告诉我如何解决这个问题。
最佳答案
尝试使用:
image.clipsToBounds = YES;
关于iOS layer.borderWidth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26229085/