我知道每个 imageView 都有一个图层(我们可以使用 :imageView.layer 访问它)。我想使用我的 imageView
图层并向其图层添加一个子图层:shapeLayer
(即 CAShapeLayer)我的代码不起作用,它不显示形状层!
- (void)viewDidLoad
{
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
[self.view addSubview:imageView];
}
- (void)anotherMethod
{
[imageView.layer addSublayer:shapeLayer];
}
请问我该如何解决这个问题?
最佳答案
试试这个:
[outputImage.layer insertSublayer:shapeLayer atIndex:0];
关于iphone - 将 subLayer 添加到 imageView.layer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8630869/