ios - Use NS[UI]ScrollView to manipulate projection -
i have simple metal setup draw image in middle of mtkview
. wish add pinch zoom , other functionality have in scroll views, can zoom image , move around thresholds.
i don't want implement myself since app live in both mac os , ios , twice more code support , write.
is there way use default scroll view controlls manipulate projection? mean set scroll view somehow on top of view , data in delegate manner or whatever.
any appreciated!
you may want try metal2dscrollable
sample code. idea that:
- place mtkview behind (not subview) uiscrollview,
- place dummy content view subview of uiscrollview
- make dummy content view target of zooming
- set uiscrollview such contentsize, contentinset etc.
- make both uiscrollview , dummy content view transparent
- calculate transform dummy content view's bounds -> mtkview's coordinate -> device coordinate
- apply transform when rendering metal
so, mtkview not in uiscrollview, tricks fools user's eyes.
https://github.com/codelynx/metal2dscrollable
the same technique may work macos tweaks, haven't tried.
Comments
Post a Comment