April 2020
Beginner
316 pages
8h 20m
English
Now, let's hook up a button that we'll use to call and select our images from our library. For simplicity, we'll amend our previously created Image View to be a Button (with our image inside). Amend the following Image code to wrap this within a button control:
Button(action: { self.showingImagePicker.toggle()}) { Image(uiImage: self.libraryImage ?? (UIImage(named: "placeholder-add-image") ?? UIImage())) .resizable() .aspectRatio(contentMode: .fit) .clipShape(Circle()) .overlay(Circle().stroke(Color.purple, lineWidth: 3).shadow(radius: 10)) .frame(maxWidth: .infinity, maxHeight: 230) .padding(6)}.sheet(isPresented: $showingImagePicker) { ImagePicker(image: self.$libraryImage)}.buttonStyle(PlainButtonStyle())Read now
Unlock full access