SwiftUI Button not being tapped - ios

I Have a button embedded inside a Hstack inside a Vstack inside a ZStack inside a Vstack inside a geometryReader in swiftui that does not get tapped. I put a print statement inside and whenever I tried to Tap the button, the print statement won't print. Can anyone help me out here? Thanks. Heres my code:
struct DetailedGroupView: View {
#State var actrualImage: Image?
#State var title = "title"
#State var description = "description"
#State var sgName = "sgName"
#State var membersCount = 0
#Environment(\.presentationMode) var presentationMode
var body: some View {
GeometryReader{ geo in
VStack{
ZStack{
(self.actrualImage ?? Image("earthPlaceholder"))
.resizable()
.aspectRatio(contentMode: .fill)
VStack{
Spacer()
HStack{
//This button doesn't work
Button(action: {
print("Button Tapped")
self.presentationMode.wrappedValue.dismiss()
}, label: {
Image(systemName: "chevron.left").foregroundColor(.white)
}).padding()
Text(self.title)
.font(.largeTitle)
.fontWeight(.bold)
.multilineTextAlignment(.leading)
.foregroundColor(.white)
.padding()
.minimumScaleFactor(0.5)
Spacer()
}
HStack{
Text(self.description)
.font(.custom("Open Sans", size: 18))
.fontWeight(.ultraLight)
.multilineTextAlignment(.leading)
.foregroundColor(.white)
.padding()
Spacer()
}
Spacer()
HStack{
Image(systemName: "person.2.fill").foregroundColor(.white).padding(.leading)
Text("\(self.membersCount)")
.font(.custom("Open Sans", size: 12))
.fontWeight(.semibold)
.foregroundColor(.white)
Spacer()
Text(self.sgName)
.font(.custom("Open Sans", size: 12))
.fontWeight(.semibold)
.foregroundColor(.white)
.padding()
}.padding()
}.frame(width: geo.size.width, height: 294)
}.frame(width: geo.size.width, height: 294)
.clipShape(RoundedRectangle(cornerRadius: 12))
.edgesIgnoringSafeArea(.top)
Spacer()
ScrollView(showsIndicators: false){
VStack{
Spacer()
}.onAppear{
self.actrualImage = Image("globePlaceholder")
}
}
}
}.navigationBarBackButtonHidden(true)
}
}

Just tested this same code on both XCode 11.5 and 12.0, and the button works fine... be sure to test it on a simulator not on the preview/canvas

Related

SwiftUI - Image and text in the same line

Lately started learning SwiftUI and I ran into a problem.
I tried putting image and text component and it didn't break the line.
Someone have an idea to solve it?
This is my code:
struct RestaurantOverlay: View {
var amountOfStars: Int
var body: some View {
ZStack {
Text("Burger")
.font(.system(size: 17.5))
.foregroundColor(.white)
.fontWeight(.heavy)
Image(systemName: "star.fill")
.font(.system(size: 13))
.foregroundColor(.white)
.fontWeight(.medium)
}
.padding(10)
.background(Color.black)
.opacity(0.8)
.cornerRadius(10.0)
}
}
ZStack {
HStack {
Text("Burger")
.font(.system(size: 17.5))
.foregroundColor(.white)
.fontWeight(.heavy)
Image(systemName: "star.fill")
.font(.system(size: 13))
.foregroundColor(.white)
.fontWeight(.medium)
}
.padding(10)
.background(Color.black)
.opacity(0.8)
.cornerRadius(10.0)
}
You can change HStack to VStack if you want vertically.

iOS 15 Keyboard hides textfield

I am trying to create a messaging page layout but the keyboard hides the textfield and moves everything to the the top. I have looked at many tutorials online and replicated them exactly but none of them seem to work.
Here is all the code I have written:
struct MessagingPage: View {
var user: OfficialUserModel
#ObservedObject private var vm = TheUserModel()
#State var screenWidth = UIScreen.main.bounds.width
#State var imageSize = UIScreen.main.bounds.width / 12
#State var text = ""
#State var show = false
#Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView{
ZStack{
VStack{
HStack{
Spacer()
NavigationLink(destination: UserDisplayPage(user: user)) {
HStack{
WebImage(url: URL(string: user.imageURL ))
.resizable()
.aspectRatio( contentMode: .fill)
.frame(width: imageSize, height: imageSize
)
.cornerRadius(imageSize/2)
VStack(alignment: .leading){
Text(user.FullName)
.font(.body)
.fontWeight(.bold)
.foregroundColor(.white)
Text("\(user.City) , \(user.Country)")
.font(.caption)
.fontWeight(.semibold)
.foregroundColor(.white)
}
}
}
Spacer()
HStack{
Button{
presentationMode.wrappedValue.dismiss()
} label: {
Image(systemName: "chevron.down")
.font(.title)
.foregroundColor(.myWhite)
}
}
.padding(.trailing)
}
.padding(.top, 30)
.frame(height: 75)
.background(Color.mainBlack)
ScrollView{
Spacer()
ForEach(0..<2){ num in
HStack{
Spacer()
HStack{
Text("Hello \(user.firstName)")
.foregroundColor(.orange)
}
.padding()
.background(Color.mainBlack)
.cornerRadius(15)
.shadow(color: .orange, radius: 2)
}
.padding(.horizontal)
.padding(.top, 8)
}
HStack{Spacer()}
HStack{
HStack{
Text("\(user.FullName) is unable to recieve your message at this time. Please try again at a later time.")
.foregroundColor(.green)
}
.padding()
.background(Color.mainBlack)
.cornerRadius(15)
.shadow(color: .green, radius: 2)
Spacer()
}
.padding(.horizontal)
.padding(.top, 8)
HStack{Spacer()}
}
.background(Color.mainBlack)
ZStack{
HStack{
HStack{
HStack{
TextField("Say Something...", text: self.$text)
.placeholder(when: text.isEmpty) {
Text("Say Something...").foregroundColor(.myWhite.opacity(0.5))
}
.frame(width: screenWidth - 200, height: screenWidth/25)
.foregroundColor(.myCyan)
.accentColor(.myCyan)
.background(Color.mainBlack)
.textContentType(.emailAddress)
if !text.isEmpty{
Button{
print(text)
self.text = ""
}label: {
Image(systemName: "paperplane")
.foregroundColor(.myCyan)
.font(.system(size: 20))
}
}
else{
Button{
print("Show more options")
}label: {
Image(systemName: "plus")
.foregroundColor(.myCyan)
.font(.system(size: 20))
}
}
}
.frame(width: screenWidth - 150, height: screenWidth/25)
.padding()
.background(Color.mainBlack)
.cornerRadius(30)
.shadow(color: .myCyan, radius: 5)
.padding(.bottom,5)
}
}
.padding(.bottom, 50)
.frame(width: screenWidth)
}
}
}
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
.background(Color.mainBlack)
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
}
I want the the textfield to move up as well as the messages in the scrollview but the top HStack with the user image and back/dismiss button should remain in place.
You really have a lot of code in there - and two reasons to clean it up:
To get a good answer, you need to post a minimal, reproducible example, which may also help you debug the code before posting it
Many lines of code are redundant or useless, for example:
Why using things like HStack{Spacer()} instead of Spacer(), which by the way is not needed in this context?
Why having a stack that has only another stack inside?
Coming to your issue, the problem is that one of the redundant modifiers is preventing the text file to move up, and this is the line to delete:
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
Why setting a frame that is as high and large as much as the screen? This is forcing the text field to stay at the bottom.
I tried to do some clean up, I bet some more can be done - see the code below, now the keyboard does not cover the text field anymore:
struct MessagingPage: View {
// Removed some lines of code to reproduce your issue
#State var screenWidth = UIScreen.main.bounds.width
#State var imageSize = UIScreen.main.bounds.width / 12
#State var text = ""
#State var show = false
#Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView{
// What is the purpose of this ZStack???
// ZStack{
VStack{
HStack{
Spacer()
NavigationLink(destination: Text("Hello")) {
Text("Top bar")
}
Spacer()
HStack{
Button{
presentationMode.wrappedValue.dismiss()
} label: {
Image(systemName: "chevron.down")
.font(.title)
.foregroundColor(.white)
}
}
.padding(.trailing)
}
.padding(.top, 30)
.frame(height: 75)
.background(Color.black)
ScrollView{
// All the views inside the Scrollview need to be inside a VStack
VStack {
// Why this spacer???
// Spacer()
ForEach(0..<2){ num in
HStack{
Spacer()
HStack{
Text("Hello username")
.foregroundColor(.orange)
}
.padding()
.background(Color.black)
.cornerRadius(15)
.shadow(color: .orange, radius: 2)
}
.padding(.horizontal)
.padding(.top, 8)
}
HStack{Spacer()}
HStack{
HStack{
Text("User is unable to receive your message at this time. Please try again at a later time.")
.foregroundColor(.green)
}
.padding()
.background(Color.black)
.cornerRadius(15)
.shadow(color: .green, radius: 2)
Spacer()
}
.padding(.horizontal)
.padding(.top, 8)
// Why a Spacer inside an HStack???
// HStack{Spacer()}
}
.background(Color.black)
}
// What is the purpose of this ZStack???
// ZStack{
// Why an HStack that has only an HStack inside??
// HStack{
// Why an HStack that has only an HStack inside??
// HStack{
HStack{
TextField("Say Something...", text: self.$text)
.frame(width: screenWidth - 200, height: screenWidth/25)
.foregroundColor(.cyan)
.accentColor(.cyan)
.background(Color.white)
.textContentType(.emailAddress)
if !text.isEmpty{
Button{
print(text)
self.text = ""
}label: {
Image(systemName: "paperplane")
.foregroundColor(.cyan)
.font(.system(size: 20))
}
}
else{
Button{
print("Show more options")
}label: {
Image(systemName: "plus")
.foregroundColor(.cyan)
.font(.system(size: 20))
}
}
}
// Are you sure you want set the height of this stack based on the width?
// .frame(width: screenWidth - 150, height: screenWidth/25)
.frame(width: screenWidth - 150)
.padding()
.background(Color.black)
.cornerRadius(30)
.shadow(color: .black, radius: 5)
.padding(.bottom,5)
// }
// }
.padding(.bottom, 50)
.frame(width: screenWidth)
// }
}
// }
// Why setting a frame that is high and large as much as the screen??
// .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
.background(Color.black)
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
}

The logic of clicking like in SwiftUI

world! I want to make sure that the like is placed only on one card, and not on all at once. I wrote the logic of painting the like and clicking it. But this applies to all cards, not just the one where I clicked like.
How can I change the logic so that the like is placed only on the card I clicked on?
Below the code CellView() is a cell with a card, which I then use in another view
struct CellView: View{
//MARK: - PROPERTIES
#AppStorage("isLiked") var isLiked: Bool = false
var data: Model
//MARK: - BODY
var body: some View{
VStack{
VStack{
AnimatedImage(url: URL(string: data.photo)!)
.resizable()
.aspectRatio(contentMode: .fit)
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Color("GrayWhite"), lineWidth: 0.5)
)
}.background(Color.white)
.cornerRadius(10)
VStack{
HStack{
Text("\(data.price) ₽")
.font(.system(size: 16, weight: .bold))
.foregroundColor(Color("BlackWhite"))
Spacer()
Button(action: {
self.isLiked.toggle()
}, label: {
Image(systemName: isLiked ? "heart.fill" : "heart")
.frame(width: 22, height: 22)
.foregroundColor(isLiked ? .red : .black)
})
}.padding(.bottom, 1)
HStack{
Text(data.company)
.font(.system(size: 14, weight: .bold))
.lineLimit(1)
.foregroundColor(Color("BlackWhite"))
Spacer()
}
HStack{
Text(data.name)
.font(.system(size: 14, weight: .bold))
.lineLimit(1)
.foregroundColor(.gray)
Spacer()
}
}
.padding(.horizontal, 2)
}
.padding(5)
}
}
Thank you in advance for your help
Each cell has to be identified for Swift to know what is liked.
import SwiftUI
struct CardData: Identifiable {
var id: String = UUID().uuidString
// add the rest of the data associated with the cards, company, etc.
}
And if we want to follow the MVVM-structure you create a separate file for the functions (when we check like and unlike each card).
class CellViewModel: ObservableObject {
#Published var card: CardData!
#Published var isLiked = false
func like() {
isLiked.toggle()
}
}
Now all our CellViews can be liked seperately (I removed some your inputs, for test)
struct CellView: View{
//MARK: - PROPERTIES
#ObservedObject var cellViewModel: CellViewModel = CellViewModel()
init(cardData: CardData) {
self.cellViewModel.card = cardData
}
//MARK: - BODY
var body: some View{
VStack{
VStack{
Image(systemName: "circle")
.resizable()
.aspectRatio(contentMode: .fit)
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Color("GrayWhite"), lineWidth: 0.5)
)
}.background(Color.white)
.cornerRadius(10)
VStack{
HStack{
Text(" ₽")
.font(.system(size: 16, weight: .bold))
.foregroundColor(Color("BlackWhite"))
Spacer()
Button(action: {
cellViewModel.like()
}, label: {
Image(systemName: cellViewModel.isLiked ? "heart.fill" : "heart")
.frame(width: 22, height: 22)
.foregroundColor(cellViewModel.isLiked ? .red : .black)
})
}.padding(.bottom, 1)
HStack{
Text("company")
.font(.system(size: 14, weight: .bold))
.lineLimit(1)
.foregroundColor(Color("BlackWhite"))
Spacer()
}
HStack{
Text("name")
.font(.system(size: 14, weight: .bold))
.lineLimit(1)
.foregroundColor(.gray)
Spacer()
}
}
.padding(.horizontal, 2)
}
.padding(5)
}
}
Testing liking seperately:
struct ContentView: View {
var body: some View {
VStack {
CellView(cardData: CardData())
CellView(cardData: CardData())
CellView(cardData: CardData())
CellView(cardData: CardData())
}
}
}

iOS: How to make my image logo at the top of the page SwiftUI

firstly I am really new to iOS development and Swift (2 weeks coming here from PHP :))
I am building my simple Login page and wondering how to make my Logo image at the top of the page. Also I am wondering if I have done my layout wrong to get the desired layout as in the screenshot. Would appreciate the help on this.
(Logo scribbled out in the screen shot needs to go to the top outside the white background)
Thanks
LoginView:
import SwiftUI
struct LoginView: View {
#State private var email: String = ""
#State private var password: String = ""
let verticalPaddingForForm = 40
var body: some View {
ZStack {
Color(red: 20/225.0 ,green: 22/225.0 , blue: 25/225.0)
VStack(spacing: CGFloat(verticalPaddingForForm)) {
Image("logo")
.resizable()
.scaledToFit()
Divider()
VStack {
TextField("Email", text: $email)
.padding(.horizontal, 30).padding(.top, 20)
Divider()
.padding(.horizontal, 30)
SecureField("Password", text: $password)
.padding(.horizontal, 30).padding(.top, 20)
Divider()
.padding(.horizontal, 30)
}
.background(Color(.white))
Text("Forgotten Password")
.foregroundColor(.blue)
.font(.system(size: 15))
Button(action: /*#START_MENU_TOKEN#*/{}/*#END_MENU_TOKEN#*/) {
Text("Login")
.padding()
.font(.system(size: 20))
}
.background(Color.black)
.foregroundColor(Color.white)
.cornerRadius(10)
.padding(.top, 0)
.padding(.bottom, 20)
}
.padding(.horizontal, CGFloat(verticalPaddingForForm))
.background(Color(.white))
VStack{
Spacer()
Button(action: /*#START_MENU_TOKEN#*/{}/*#END_MENU_TOKEN#*/) {
Text("Register")
.padding()
.font(.system(size: 40))
}
.background(Color(red: 20/225.0 ,green: 22/225.0 , blue: 25/225.0))
.foregroundColor(Color.white)
.cornerRadius(10)
.padding()
}
}.ignoresSafeArea()
};
}
ContentView:
import SwiftUI
struct ContentView: View {
var body: some View {
LoginView()
}
}
extension UIDevice {
var hasNotch: Bool {
let bottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
return bottom > 0
}
}
Try below code-:
Use a ZStack to give a backgroundColor to your view, and give that a modifier of .ignoresSafeArea().
Use VStack inside ZStack to layout other view components. I have done few modifications on my side.
struct LoginView: View {
#State private var email: String = ""
#State private var password: String = ""
let verticalPaddingForForm = 40
var body: some View {
ZStack() {
Color(red: 20/225.0 ,green: 22/225.0 , blue: 25/225.0).ignoresSafeArea()
VStack(spacing:15){
Image(systemName: “logo")
.resizable()
.scaledToFit()
.frame( height: 200)
.foregroundColor(Color.white)
.padding([.top],15)
VStack(spacing: CGFloat(verticalPaddingForForm)) {
VStack {
TextField("Email", text: $email)
.padding(.horizontal, 30).padding(.top, 20)
Divider()
.padding(.horizontal, 30)
SecureField("Password", text: $password)
.padding(.horizontal, 30).padding(.top, 20)
Divider()
.padding(.horizontal, 30)
}
.background(Color(.white))
.padding([.top])
Text("Forgotten Password")
.foregroundColor(.blue)
.font(.system(size: 15))
Button(action: {}) {
Text("Login")
.padding()
.font(.system(size: 20))
}
.background(Color.black)
.foregroundColor(Color.white)
.cornerRadius(10)
.padding([.bottom])
}
.background(Color(.white))
Spacer()
Button(action: {}) {
Text("Register")
.padding()
.font(.system(size: 40))
}
.foregroundColor(Color.white)
.cornerRadius(10)
}
}
};
}
struct Test1: View {
var body: some View {
LoginView()
}
}
extension UIDevice {
var hasNotch: Bool {
let bottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
return bottom > 0
}
}
You can use ZStack (alignment: .top) to set the alignment from the top. And then you can use a Spacer() at the end of the second VStack to expand the view.
The following code works for me. It's your code with little changes. Also, I suggest you create a subview to better organize your code, instead of writing all views within the same view.
import SwiftUI
struct LoginView: View {
#State private var email: String = ""
#State private var password: String = ""
let verticalPaddingForForm = 40
var body: some View {
ZStack (alignment: .top){
Color(red: 20/225.0 ,green: 22/225.0 , blue: 25/225.0)
VStack(spacing: CGFloat(verticalPaddingForForm)) {
Image(systemName: "gear")
.resizable()
.scaledToFit()
.frame(width: 100)
Divider()
VStack {
TextField("Email", text: $email)
.padding(.horizontal, 30).padding(.top, 20)
Divider()
.padding(.horizontal, 30)
SecureField("Password", text: $password)
.padding(.horizontal, 30).padding(.top, 20)
Divider()
.padding(.horizontal, 30)
}
.background(Color(.white))
Text("Forgotten Password")
.foregroundColor(.blue)
.font(.system(size: 15))
Button(action: /*#START_MENU_TOKEN#*/{}/*#END_MENU_TOKEN#*/) {
Text("Login")
.padding()
.font(.system(size: 20))
}
.background(Color.black)
.foregroundColor(Color.white)
.cornerRadius(10)
.padding(.top, 0)
.padding(.bottom, 20)
Spacer()
}
.padding(.horizontal, CGFloat(verticalPaddingForForm))
.background(Color(.white))
VStack{
Spacer()
Button(action: /*#START_MENU_TOKEN#*/{}/*#END_MENU_TOKEN#*/) {
Text("Register")
.padding()
.font(.system(size: 40))
}
.background(Color(red: 20/225.0 ,green: 22/225.0 , blue: 25/225.0))
.foregroundColor(Color.white)
.cornerRadius(10)
.padding()
}
}
}
}
struct LoginView_Previews: PreviewProvider {
static var previews: some View {
LoginView()
}
}
Just put Spacer() between Image("logo") and Divider() to push your logo to the top of the screen

Navigation link and scroll view issue SwiftUI

I have a problem with the navigation link and SwiftUI. The navigation bar desapear and my scroll view go up. I have upload a video of the issue on Facebook here the link : the link of the video
This is the code of my main view :
struct MainView: View {
let date = Date()
let calendar = Calendar.current
static let formatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .short
return formatter
}()
//MARK: Properties
#ObservedObject var session = FirebaseSession()
let user = Auth.auth().currentUser
#State private var showModal = false
var body: some View {
NavigationView{
// Group {
ZStack {
if session.session != nil {
ScrollView {
VStack{
ScrollView(.horizontal, showsIndicators: false){
HStack{
NavigationLink(destination: RedactorView()) {
RedactorListItem()
}.buttonStyle(PlainButtonStyle())
RedactorListItem()
RedactorListItem()
RedactorListItem()
RedactorListItem()
RedactorListItem()
}//.padding()
}
VStack(alignment: .leading, spacing: 5) {
HStack {
Text("Les derniers médias")
.font(.largeTitle)
.bold()
Spacer()
Text("Voir plus >")
.padding(8)
.background(Color(UIColor.secondarySystemBackground))
.clipShape(Capsule())
}.padding(.horizontal)
ScrollView(.horizontal, showsIndicators: false){
HStack{
NavigationLink(destination: MotherView(viewRouter: ViewRouter())){
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
}.buttonStyle(PlainButtonStyle())
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
}
}
HStack {
Text("Les derniers articles :")
.font(.largeTitle)
.bold()
Spacer()
Text("Voir plus >")
.padding(8)
.background(Color(UIColor.secondarySystemBackground))
.clipShape(Capsule())
}.padding(.horizontal)
ArticleListRow()
ArticleListRow()
ArticleListRow()
}
}
.navigationBarTitle("WYN")
.navigationBarHidden(true)
}.navigationViewStyle(StackNavigationViewStyle()).padding(.top, 90)
ZStack{
VStack{
HStack{
VStack(alignment: .leading) {
VStack {
VStack(alignment: .leading){
HStack{
Text("What You Need")
.font(.system(.largeTitle, design: .serif))
.bold()
Spacer()
Button(action: {
self.showModal.toggle()
}) {
Image(systemName: "person.crop.circle.fill")
.font(.largeTitle)
.foregroundColor(.primary)
}
.sheet(isPresented: $showModal){
SettingView(showModal: self.$showModal)
}
}
Text("\(date, formatter : MainView.self.formatter)")
.font(.callout)
.bold()
.foregroundColor(Color(UIColor.systemGray4))
}
/*
Rectangle()
.frame(height: 2)
.cornerRadius(1)
.foregroundColor(Color(UIColor.systemGray5))
*/
}
.padding(.horizontal)
.padding(.top, 20)
}.background(Color(UIColor.systemBackground)).frame(minWidth: 0, maxWidth: .infinity).frame(height: 75)
}
Spacer()
}
}
} else {
Authentification()
}
}
.onAppear(perform: getUser)
//}
.navigationBarTitle("Menu Principal")
.navigationBarHidden(true)
}.navigationViewStyle(StackNavigationViewStyle())
}
//MARK: Functions
func getUser() {
session.listen()
}
}
and this the code of my detail view :
import SwiftUI
struct RedactorView: View {
var body: some View {
// NavigationView {
ScrollView {
VStack(alignment: .leading) {
HStack{
Image("P1")
.resizable()
.scaledToFill()
.frame(width: 115, height: 115)
.clipShape(Circle())
.padding(.trailing)
VStack(alignment: .leading){
Text("Prénom")
.font(.largeTitle)
.bold()
Text("Nom")
.font(.largeTitle)
.bold()
HStack {
VStack(alignment: .center){
Text("10")
.bold()
Text("Articles")
.foregroundColor(Color(UIColor.secondaryLabel))
}
VStack(alignment: .center){
Text("5")
.bold()
Text("Medias")
.foregroundColor(Color(UIColor.secondaryLabel))
}
}.padding(.top)
}
Spacer()
}.padding(.horizontal)
ScrollView(.horizontal, showsIndicators: false) {
HStack {
HStack{
Text("Email")
.bold()
Image(systemName: "envelope.fill")
// .foregroundColor(Color(UIColor.systemBlue))
}.foregroundColor(Color(UIColor.systemBlue))
.padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
HStack{
Text("Instagram")
.bold()
Image(systemName: "heart.fill")
}.foregroundColor(Color(hue: 0.93, saturation: 0.81, brightness: 0.84)).padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
HStack{
Text("Message")
.bold()
Image(systemName: "message.fill")
}.foregroundColor(Color(UIColor.systemGreen))
.padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
HStack{
Text("Téléphone")
.bold()
Image(systemName: "phone.fill")
}.foregroundColor(Color(UIColor.systemGreen)).padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
}.padding()
}
VStack(alignment: .leading, spacing: 5) {
Text("Ses Medias :")
.font(.largeTitle)
.bold()
.padding(.leading)
ScrollView(.horizontal, showsIndicators: false){
HStack{
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
}
}
Text("Ses Articles :")
.font(.largeTitle)
.bold()
.padding(.leading)
ArticleListRow()
ArticleListRow()
ArticleListRow()
}
}.navigationBarTitle("Redactor")
}
// }//.padding(.top, -20)
}
}
I don't know what is the solution of this I hope it open normal but it don't find and I have the same with all scroll view. Please help me.
it is missing a .edgesIgnoringSafeArea(.top) on the navigationView which can give you the safeArea guard.

Resources