iphone - 将 subLayer 添加到 imageView.layer

标签 iphone objective-c cocoa-touch uiimageview calayer

我知道每个 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/

相关文章:

iphone - 我的 iPhone Simulator 3.0 地址簿是空的!

iphone - 为什么静态 NSString 会泄漏?

ios - 如何将 View Controller 推送到 iOS 标签栏中的导航 Controller

iPhone - Grand Central Dispatch 在 iPhone 4S 上无法正常工作

ios - 如何更改默认的 iOS 后退行为以避免在两个 View 之间来回切换?

ios - SpriteKit .plist 问题 xcode 6

iphone - 核心数据 : Dealing with polymorphic associations?

iphone: 在 UIWebView 中弹出按钮

ios - NSMutableArray 项完全相同

ios - 为什么 Keychain 比保存在文件中的加密数据更安全?