Re: NSView vs CALayer
parfeon <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
Christiaan Hofman-2 wrote: > > > On Sep 29, 2009, at 12:32, parfeon wrote: > >> >> Hello everyone. >> >> Working on project which draws some parts of its UI with CoreAnimation >> CALayers. Currently i need create some cover view, which will appear >> over >> whole UI (that NSView always there, coz it will response on user >> drag n >> drop). >> I'm stumbled with such problem as shown on screen >> >> http://www.nabble.com/file/p25659257/nsviewvscalayer.png >> >> http://img44.imageshack.us/i/nsviewvscalayer.png/ >> >> Transparent view overlays the view in which I used CALayers for >> drawing. >> Dunno why, but when I change that subview (with CALayers) to any >> other (w/o >> CoreAnimation drawing... some standard IB elements) everything looks >> great. >> >> >> Can someone help me with this? >> >> Thanks > > I really can't understand your message and in particular what your > specific problem is. But the basic fact is that layer-hosting views > cannot have subviews, so I guess that's where you run into. > > Christiaan > > _______________________________________________ > MacOSX-dev mailing list > [email protected] > http://www.omnigroup.com/mailman/listinfo/macosx-dev > > Quoted from: http://www.nabble.com/NSView-vs-CALayer-tp25659257p25663495.html My bad. Will try to explain all what I have done. Currently I want try to make behavior of window like in Transmission when You drag over .torrent file (appears blacj cover with info on center) 1. I have XIB with such structure as shown on image: http://img21.imageshack.us/img21/2967/mainxibstructure.png . I've placed there split view (2 views inside). Left view used for displaying source list (as we can see here http://www.nabble.com/file/p25659257/nsviewvscalayer.png) and the right view i used for displaying information (Place Holder). And also there over that split view "Drag&Drop Layer" (custom NSView where with CA I'm drawing transparent background); 2. After application do launch, my code placing inside "Place Holder" (with addSubview:) new custom view (instance of NSView placed in other XIB file); 3. On awakeFromNib that custom view creates CALayers and draws there content (background and buttons). On 'self' of custom view I'm setting setLayer to "baseLayer" (which holds all graphics) and then call setWantsLayer:YES; 4. And at the end we can see picture as I shown: http://www.nabble.com/file/p25659257/nsviewvscalayer.png It look's like "Drag&Drop Layer" cut out piece of custom view inside "Place Holder". Here is the code which I use to insert custom view inside "Place Holder": - (void)changeViewTo:(id)view{ if(currentView != [view view]) currentView = nil; if([[placeHolderView subviews] count] == 0){ [placeHolderView addSubview:[view view]]; else [placeHolderView replaceSubview:[[placeHolderView subviews] objectAtIndex:0] with:[view view]]; currentView = [view view]; [currentView setFrame:[[currentView superview] frame]]; [currentView setFrameOrigin:NSMakePoint(0,0)]; [currentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; } currentView - is type of NSView placeHolderView - is IBOutlet on "Place Holder" view of NSView class But when I'm adding inside placeHolder other custom view (which is inside loaded XIB) we can see this picture http://img182.imageshack.us/img182/1951/nsviewvsnsview.png In that view placed standard elements, which not drawn in real time. Sp till now I can't understand what I'm doing wrong. Can someone help with this? -- View this message in context: http://www.nabble.com/NSView-vs-CALayer-tp25659257p25665815.html Sent from the OmniGroup - MacOSX-Dev mailing list archive at Nabble.com.