Reputation: 263
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?
Upvotes: 0
Views: 956
Reputation: 6638
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
Upvotes: 2