I have a layer-hosting NSView (-isFlipped = YES) with three layer-hosting subviews. The subviews are a header, a content area, and a footer. The header has a disclosure triangle which will collapse the content view and just show the header and footer stuck together.
I can accomplish this pretty easily with Core Animation, but there is a strange problem happening when I resize the view. If I resize the view horizontally, I want all three subviews to match the new width. If I resize it vertically, I want the subviews to stay where they are (i.e. the bottom edge of the view should be able to move without affecting the subview's position (except clipping of course). The reason for this is that I need to collapse the size of the view when the contentView is faded out.
What is actually happening is that all three subviews are being pushed up above the top of the view when the height is changed... and then snap back in place when the horizontal is开发者_开发知识库 changed. It has something to do with the combination of both the view and the subViews, because if the subviews are placed directly in the window, they behave properly. Also, I tried adding a button into the view and it behaved normally.
I was able to get the button to misbehave in the same way by making it layer-backed too... so I think the layer backing has something to do with it.
It is like the backing layers are getting stuck to the parent view as it resizes and being pushed up even though the coordinates are flipped.
Any ideas?
Layer hosting views shouldn't have subviews. See -(void)setWantsLayer: documentation in NSView class reference:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html%23//apple_ref/occ/instm/NSView/setWantsLayer:
Root view should maybe be a layer backed view instead of a layer hosting one?
精彩评论