Search code examples
objective-cuiimagecalayer

Draw UIImage in a CALayer


Is it possible to draw an existing png image inside a CALayer? If not, how can I have the image as a sublayer of a CALayer?


Solution

  • It is possible, just set layer's contents:

    layer.contents = (id) [UIImage imageNamed:@"yourImageNamed"].CGImage;