将subLayer添加到imageView.layer [英] add subLayer to a imageView.layer

查看:176
本文介绍了将subLayer添加到imageView.layer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我知道每个imageViews都有一个图层(我们可以通过:imageView.layer访问它)。我想使用我的 imageView 的图层并添加一个subLayer所在的层: shapeLayer (即CAShapeLayer)我的代码不起作用,它不显示形状层!

well I know that every imageViews have a layer (we can access it with :imageView.layer).I would like to use the layer of my imageView and add a subLayer to it's layer:shapeLayer(that is a CAShapeLayer) My code doesn't work, it doesn't show the shape layer!

- (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];

这篇关于将subLayer添加到imageView.layer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆