简体   繁体   中英

How to convert NSView to CALayer?

I have made a video player,and images are draw in a NSView.Have any method to convert NSView to CALayer?I try to use layer-hosting view ,but developer document said can not add any subviews to layer-hosting view .Anyone can give me some suggestions?This code can run in OSX 10.6.8,but OSX 10.7 and 10.8.

mDisplayView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
mDisplayLayer = [[CALayer layer] retain];

[mDisplayView setLayer:mDisplayAudioLayer];
[mDisplayView setWantsLayer:YES];
[mDisplayView addSubview:mContentView];
[mRootLayer addSublayer:mDisplayAudioLayer];

The image of video had been drawn on mContentView .I just need find a way to make the mContentView into CALayer ,is that possible?

You do not convert a view to a layer - you either draw into a view traditionally by overriding drawRect: or you switch it to layer-backed view and use CoreAnimation.

Best to start here to understand the basic concepts involved:

Core Animation Programming Guide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM