This question already has answers here:
How to hide the home indicator with SwiftUI?
(6 answers)
Hide the Home Indicator in Swift 2.0
(1 answer)
Closed 1 year ago.
I have a View that has some VStacks and ZStacks (top bar, carousel, detail view with if condition).
This code changes fullscreen/not fullscreen appearance:
.edgesIgnoringSafeArea(viewModel.currentItem != nil ? .all : [])
But even without .all activated I have a strange bottom Home bar appearance like there is a gradient/shadow overlay on it:
What could cause this and how to avoid this?
P.S. I also noticed in my UI hierarchy that HostingViewController is a subview of the UIDropShadowView.
P.P.S. It also doesn't go when navigation to other view with NavigationLink
That is not an issue, it should be like that, since we have no touch id in new iPhone models, that things play as kind of help in Screen. And when you use edgesIgnoringSafeArea in your code, you get access to under area and back area of that shape for Color works!
That shape is used for Swipe up to go iPhone main screens.
Look at the iPhone 8, it has touch, and look at iPhone 11, No touch ID!
Related
I'm building a photo gallery using SwiftUI, and am trying to ensure that a user can smoothly scroll through thousands of photo thumbnails without performance degradation or visible load times for each photo.
So far, my research has led me to use a lazyvgrid within a ScrollView, which seems to perform better than a lazyvstack or a normal grid when working with a large data set. However, when scrolling through the lazyvgrid, it takes a moment for each new row of thumbnails to load (since lazyvgrid is lazy), and this is especially noticeable when scrolling very quickly.
Ultimately, I'm wondering how other apps with photo galleries get around this issue. Is it impossible to avoid when using SwiftUI, and would I need to use something like UIKit's CollectionView with prefetching?
Here's what I'm doing currently:
ScrollView {
LazyVGrid(columns: vGridLayout) {
ForEach(photoLibraryService.items, id: \.self) { asset in
PhotoThumbnailView(assetLocalId: asset.localIdentifier, mediaType: asset.mediaType, duration: asset.duration)
}
}
}
And here's what it looks like when I scroll through it quickly:
I want to implement a vertical scroll page like system workout app.
Now I can get a similar effect with this:
TabView {
page1
.rotationEffect(.degrees(90))
page2
.rotationEffect(.degrees(90))
}.tabViewStyle(.page(indexDisplayMode: .automatic))
.rotationEffect(.degrees(-90))
But not good as system workout app does. It supports digital crown and dynamic show indicator and custom color.
So , how to implement that vertical scroll effect?
https://github.com/fredyshox/PageView
This repo works well except crown supports.
So I'm try to use ScrollViewReader to programmatically scroll a horizontal scroll view. I thought it would work like scrollToItem with .centeredHorizontally in UIKit, and for the most part it does, but the last few elements in the scroll view are being forcefully scrolled to the center of the screen, despite the fact that the scroll view isn't normally able to scroll that far over (without snapping back after releasing the drag, at least). This ends up creating white space across the trailing half of the screen.
I've seen some other questions about this and it seems like the general opinion is that it's not a bug? On the one hand I suppose we're telling the scroll view to center the item, and it's doing just that -- so, not a bug? On the other hand, that's not how similar functionality worked in UIKit. Also, this behavior is only happening on the trailing end of the scroll view! If it was the intended behavior I would expect that scrolling to the first element in the scroll view using .center anchor would force it into the center of the screen and leave leading white space, but this doesn't happen.
Is there an elegant solution to this? Or do we have to calculate the width of our elements + spacing and figure out based on the screen width whether we should anchor .center or just scroll to the last element with anchor .trailing in order to replicate the UIKit behavior?
I found a package (Amzd/ScrollViewProxy) that was made before ScrollViewReader was released that functions much the same as ScrollViewReader, but also seems to not have the bug (if it is a bug) detailed in the question.
Usage examples can be seen on the repository page, but here's a quick minimal example.
ScrollView(.horizontal) { scrollProxy in
ForEach(sections) { section in
Text(section.text)
.scrollId(section.id)
}
.onChange(of: index) {
scrollProxy.scrollTo(
sections[index].id,
alignment: .center
)
}
}
The package adds a convenience init to ScrollView to give access to the scrollProxy.
I can confirm this behavior and think it should be considered a bug. Especially since the scroll view will "jump" into position on the first touch event.
As of iOS 15.4 Beta 1 this is fixed for me. Maybe give it another try.
Since updating from Xcode 8.3 to 9, I'm seeing this weird behaviour that during push transition the target controller's Navigation Bar is loading with half height first and then settling with correct height.
Happening on all the screens of different navigation controllers.
Tried enable/disable nav bar translucent, and Safe Area Layout Guides but of no help. Happening only on iOS 11. For new view controllers too.
Screencast showing this behaviour.
Turns out that I'm using an old version of KMNavigationBarTransition library that uses method swizzling to manage navigation bar style during push transition. Update of this library fixed the issue.
I am trying to implement a help screen in my cocos2d game, using cocos2d version 2.0. My screen will have a title bar ("Help") at the top and then the rest of the screen below that is where I want to put a scrolling help section. Ideally I would be able to put both text and images into this help window.
The problem is that cocos2d does not have any functionality like UIScrollView, and from what I have seen doing Google searches, every custom solution I have found seems to have problems with various bugs popping up on various devices.
I have tried these solutions thus far:
CCScrollLayer: http://www.cocos2d-iphone.org/forum/topic/17118/page/3
Scrolling CCNode: http://tonyngo.net/2011/11/scrolling-ccnode-in-cocos2d/
CCScrollView: http://bitbattalion.com/2011/09/uikit-uiscrollview-and-cocos2d/
The closest thing I got to work was embedding a UITextView but that seemed to randomly crash after a few scrolls so it seems unreliable to me.
Does anyone know of a good simple robust solution to this problem? It seems like it should be straightforward but it isn't.
I recommend that you make new class say:(HelpViewClass) and implement it with an UIScrollView and add whatever you want to add on UIScrollView and then you can use this as a child to your layer.
Steps
Make a class - inherited with UIView
Add UIScrollView to the View.
Add Your components to it.
Add this UIView to the HelpLayer.
You can add any UIKit component to the cocos2d Layer by using this
[[[CCDirector sharedDirector] view] addSubView:scrollView];
Note : Remove all UI component when you go back from this HelpLayer.
I think this may help you !