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()
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
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
}
})
}
}