Converting views to use layer backing
Converting views to use layer backing
- Subject: Converting views to use layer backing
- From: Kenneth Baxter <email@hidden>
- Date: Wed, 16 Oct 2013 14:48:11 +0000 (GMT)
Hi, I have an NSScrollView with a document view which has subviews. All my views are flipped. I am using and targeting 10.8. I am not using autolayout (I tried it and got horribly confused by how it works with scrollviews, so just turned it off)
I turned the magnification capabilities of the scrollview on, and I set my bounds origin to near the center of the view and added the subviews.
All this works fine - the view zooms on pinch actions, the subviews resize and reposition themselves exactly as expected.
I turned on layer backing for my content view, and everything stopped working. I found the following:
- Setting the bounds origin caused the drawing of the document view and subviews to fail.
- Even with the bounds origin set, the view still tries to display as if it is drawn with the origin at 0,0.
- Resizing the window causes weird drawing glitches.
- Zooming the view also causes drawing problems, but also I can see that the magnification is being ignored when drawing.
- My subviews are not being resized when the magnification changes. Turning on setAutresizesSubviews:YES doesn't seem to help with this, but I may have the wrong resizing mask set.
The background view seldom changes, and I want to animate zooming and panning. The subviews seldom change, but need to be animated around quite a bit. It seemed as though this would be an ideal use of layer backing and only refreshing the layer content when I explicitly say it needs redrawing.
So how do I emulate the behavior that I get with the straight NSView implementation. In particular:
1. What settings do I need to use on my scrollview's document view to get it to draw with the drawing centered on the bounds center rather than the frame, and scaled according to the scrollview's magnification?
2. Do I just need the document view itself to be layer backed for this, or do I need the clip view and/or the scroll view to be layer backed too?
3. How do I get the subviews positioned relative to the bounds origin when using layer backed views?
4. How do I get the subviews to resize/reposition themselves when the magnification changes, as happened automatically when it was just NSViews?
Thanks
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden