I'm using a segmented control to navigate between tabs.
My issue is, when I scroll inside one tab, all the other tabs are also strolling. Which is something I don't want.
I want that the scrolling works only inside the selected tab and when I click on the other tabs, it shows the top of the content of the selected tab.
Check attached video : https://imgur.com/a/Oxka4hv
struct ContentView: View {
@State var selectedState = 0
@State var showTopTabBar: Bool = false
var body: some View {
ZStack (alignment: . top){
ScrollView (showsIndicators: false){
Text("Welcome")
.frame(height: 300)
Picker("Options", selection: $selectedState) {
Text("First").tag(0)
Text("Second").tag(1)
Text("Third").tag(2)
}
.pickerStyle(SegmentedPickerStyle())
.background(Color.white)
.opacity(showTopTabBar ? 0 : 1)
.readPos { rect in
if showTopTabBar != (rect.minY <= 100) {
showTopTabBar.toggle()
}
}
if (selectedState==0) {
FirstView()
}
else if (selectedState==1){
Secondview()
}
else {
ThirdView()
}
Spacer()
}
.padding()
Picker("Options", selection: $selectedState) {
Text("First").tag(0)
Text("Second").tag(1)
Text("Third").tag(2)
}
.pickerStyle(SegmentedPickerStyle())
.padding()
.background(Color.white)
.opacity(showTopTabBar ? 1 : 0)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
extension View {
func readPos(onChange: @escaping (CGRect) -> Void) -> some View {
background(
GeometryReader { geometryProxy in
Color.clear
.preference(key: CoordinatesPreferenceKey.self, value: geometryProxy.frame(in: .global))
}
)
.onPreferenceChange(CoordinatesPreferenceKey.self, perform: onChange)
}
}
private struct CoordinatesPreferenceKey: PreferenceKey {
static var defaultValue: CGRect = .zero
static func reduce(value: inout CGRect, nextValue: () -> CGRect) {}
}
and here is my code
Thanks!
Post
Replies
Boosts
Views
Activity
Hi,
I tried to get the answer to my questions in the apple guideline website, but it's very confusing and not very clear to understand.
I'm building an app where users have to pay an entrance fees to participate into time-limited events.
At the end of the each event, the money collected will be given to the winner of the event. (minus our 10% commission fees).
My questions are:
Does the fee that the user pay to enter to the event is considered to be an In-app consumable purchase?
Does Apple takes a cut of 30% on this entrance fee?
Do I have to use Apple Pay or can use a third party service like Stripe.
Is there a risk of getting my app refused from the AppStore if I don't use Apple Pay?
My main problem is that in case I have to use Apple Pay, I might have a problem in explaining to the winners of my app's events that I'm removing 40% of the reward (30% for apple and 10% our cut) 🤨.
Thanks for your help.
P.S. I found an app that do something similar and that uses Stripe for their payment : DietBet.
Hi,
I have submitted my app to TestFlight but I did receive a warning message:
The app references non-public selectors in Payload/AppNAME: dataChanged
I tried to investigate the issue but can't find a solution 🤨
Any idea?
Hi,
I have an app that allow users to post content.
I would like to add a feature that allow users to subscribe to each other in order to have access to premium content provided with the users.
My question is, how can this be implemented?
Does StoreKit provide a built-in functionality for users to subscribe to each other's content?