Post

Replies

Boosts

Views

Activity

Magnification gesture to scale ScrollView's content.
Hello! I am trying out new SwiftUI and I have to say that I love it, but I've got some problems implementing few features. First issue is that I am not sure how can I scale content of ScrollView, to make content of that View smaller, but there would be more subviews visible. Here's my code: @State private var scale: CGFloat = 1.0 var body: some View { ScrollView([.horizontal]) { HStack(alignment: .top) { ForEach(0..<5, id: \.self) { _ in ScrollView(.vertical) { LazyVGrid(columns: [GridItem(.fixed(300), spacing: 10)], spacing: 10) { ForEach(0..<5, id: \.self) { _ in Rectangle() .frame(width: 300, height: 300, alignment: .center) } } } .padding(.leading, 10) } } .scaleEffect(scale) } .gesture( MagnificationGesture() .onChanged { value  in scale = value.magnitude }) } } If You paste that code to a project, You will see that app scales whole ScrollView, not its content. And when we're talking about gestures, I would really appreciate if someone would share here how can I prioritize the gestures. Thanks for reading!
2
1
2.3k
Jun ’20
NSCollectionView Supplementary items are hidden in horizontal scroll direction configuration.
Hello! I am trying to build a collection view, which sections are rendered horizontally, but sections items are rendered vertically (like a board). It looks like that: func createCompositionalLayout() -> NSCollectionViewLayout { let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(300), heightDimension: .absolute(300)) let item = NSCollectionLayoutItem(layoutSize: itemSize) let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(300), heightDimension: .absolute(300)) let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitem: item, count: 1) let section = NSCollectionLayoutSection(group: group) section.interGroupSpacing = 10 section.orthogonalScrollingBehavior = .continuous let layoutSectionHeaderItemSize = NSCollectionLayoutSize(widthDimension: .absolute(300), heightDimension: .absolute(200)) let layoutSectionHeaderItem = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: layoutSectionHeaderItemSize, elementKind: NSCollectionView.elementKindSectionHeader, alignment: .top) section.boundarySupplementaryItems = [layoutSectionHeaderItem] let configuration = NSCollectionViewCompositionalLayoutConfiguration() configuration.scrollDirection = .horizontal configuration.interSectionSpacing = 10 let layout = NSCollectionViewCompositionalLayout(section: section, configuration: configuration) return layout } The problem lies here in two parts of code: scrollDirection (line 18) Header's code (lines 12-15) When the code is written like above, header is rendered scrollView of each section (I was able to see that with View Hierarchy tool built in Xcode), but when I comment out scrollDirection line code, headers are perfectly visible, but the layout doesn't look like I would like to. Is it a bug? I am not sure what can I do in this case. Regards!
0
0
552
Jun ’20
Drag and drop for NSCollectionView's sections
Hi, I am building an app, where I have a collection view, which is using decoration views (background for a section), supplementary items (section's header) and of course items. I would like to provide drag and drop for two kinds of views: sections (they would be moved by dragging header view) items (already implemented) The problems are in the implementation that would "take" the whole section (with decoration views, items, etc.) - I don't know how can I implement it, should I create an external class as a drag and drop delegate and assign its instance to every NSView which is a header? Or they should be self-managed (but they don't know anything about their superview)? I have tried to implement nested collection views, where item of root collection view has its own collection view and views, that are replacing all supplementary and decoration views, but I can't there make them working together, for example - I can't select multiple items from different sections as items from previous section are deselected when tapping on items in other one. Also it's tough to make drag'n'drop working between them (especially using dragging rectangle area) and it's the best way to implement it when we're talking about performance. I appreciate any kind of help/ideas to implement it. Compositional layout's code - https://developer.apple.com/forums/content/attachment/653575a8-c39c-4441-8b1f-aba6d9561e4a
8
0
1.6k
Aug ’20
How to subclass NSScrollView that is used in sections in NSCollectionViewCompositionalLayout?
Hello! I am digging a lot recently in compositional layout and I wanted to "merge" scrolling views with other collection view, but the issue is NSCollectionView has a NSScrollView instance for whole view and one instance per section (with continuous scrolling behavior). The question is how can I reach those scroll views that are holding sections? Can I subclass it or listen for mouse events without breaking basic functionality? I am building app in Swift, but I can jump into Obj-C land if I have to.
0
0
480
May ’21