可可+ CoreAnimation:自定义子视图的动画列表
几周来我一直在努力解决这个问题,尽管我从失败中学到了很多东西,但此时,我只需要一个解决方案。问题在于解压 Cocoa 中包含的看似重叠的图形和 UI API,其中许多会产生类似的效果,但具有独特的局限性,我经常在投入大量时间进行实现后才发现这些局限性。
我是 Cocoa 新手,但不是编程新手,我正在尝试创建一个具有非常定制的 UI 的 Mac 应用程序 - 想想 Capo、Garageband 或 Billings。我的窗口中的一个视图将显示子视图的有序列表,每个子视图都执行大量自定义绘图,并且每个视图都必须支持“选定”状态和拖动重新排序。子视图不需要支持被拖到其父视图之外。
理想情况下,拖动会在发生时提供动画反馈,推动相邻的同级视图以腾出空间,例如工具栏图标或 Safari 书签栏。问题是,我似乎无法找到合适的技术来解决这个问题。我已经将子视图作为 NSCollectionView 中的 NSView 子类,也作为自定义 CollectionView 中的 CALayers NSView,但似乎都没有提供完美的解决方案。也就是说,第一个选项似乎是这两个选项中更好的一个,因为它能够出色地处理鼠标事件。
我还没有尝试将其作为 TableView 执行此操作,并且在没有迹象表明我走在正确的轨道上的情况下,我不想走这条路。广泛的谷歌搜索仅显示没有任何关于支持 CoreAnimation 的重新排序或拖动的最新资源。作为 OS X UI 的标准功能,我觉得这应该更容易!
如果任何人就适合这项工作的工具提供任何帮助,我们将不胜感激。 TIA。
I've been trying to get this right for weeks now, and though I've learned a lot through my misfires, at this point, I just need a solution. The issue is with unpacking the seemingly overlapping graphics and UI APIs included in Cocoa, many of which produce similar effects, but feature unique limitations that I've often discovered only after investing many hours into an implementation.
I'm new to Cocoa, but not to programming, and I'm trying to create a Mac app with a very customized UI – think Capo, Garageband, or Billings. One view in my window will display an ordered list of subviews, each of which does a lot of custom drawing, and each must support a "selected" state and drag-reordering. The subviews do not need to support being dragged outside of their superview.
Ideally, a drag will give animated feedback as it happens, pushing neighboring sibling views to make space, e.g. toolbar icons or the Safari bookmarks bar. The trouble is, I can't seem to land on the right pack of technologies to get this right. I've done the subviews as NSView subclasses in an NSCollectionView and also as CALayers in a custom CollectionView-like NSView, and neither seems to offer the perfect solution. That said, the first option seems the better of the two for its superior handling of mouse events.
I've not yet tried doing this as a TableView, and I don't want to go down that path without some indication I'm on the right track. Extensive Googling has shown only that there aren't any up-to-date resources on CoreAnimation-enabled reordering or dragging. As such a standard feature of the OS X UI, I feel like this should be easier!
Any help from anyone on what the right tools are for this job would be greatly appreciated. TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论