Post

Replies

Boosts

Views

Activity

Change VStack color with a button inside an HStack
HI all, New to Xcode and coding. Taking the first steps Have a VStack then there is an HStack with a button. What i would like to know is when I press the button inside the HStack it will change the background color of the VStack, from black to other color. Here is a sample of the code. Thanks all for the time to reply and help. import SwiftUI struct ContentView: View { @State var index = 0 var body: some View { VStack{ Spacer() CustomTabs(index: self.$index) }.background(Color.black) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct CustomTabs : View { @Binding var index : Int var body: some View { HStack{ Button(action: { self.index = 0 }) { Spacer() Image("fdt") Spacer() }
2
0
3.4k
Feb ’21
get user name from firebase
Hello all, Trying to get a user name from firebase and then displayed on a label. Any help? heres a sample of the code. Thanks in advance import UIKit import Firebase class HomeViewController: UIViewController {           @IBOutlet weak var userName: UILabel!               override func viewDidLoad() {     super.viewDidLoad()     // Do any additional setup after loading the view.                            }       func getUserName(_ message:String) {     let uid = Auth.auth().currentUser?.uid     Database.database().reference().child("users").child(uid!).observeSingleEvent(of: .value, with: { (snapshot) in               if let dictionary = snapshot.value as? [String: AnyObject] {         self.userName.text = dictionary["firstname"] as? String                 }             })     }   }
1
0
1.6k
Mar ’21