Saturday, February 17, 2024
HomeiOS Developmentios - The right way to take away PhotosPicker background color on...

ios – The right way to take away PhotosPicker background color on VisionOS – PhotosUI SwiftUI


When utilizing PhotosPicker on visionOS the content material has a background coloration, how do I take away this? I’ve seen the identical with Stepper.

Instance:

enter image description here

Code:

import SwiftUI
import PhotosUI

struct AddImageView: View {

@State non-public var avatarItem: PhotosPickerItem?
@State non-public var avatarImage: Picture = Picture("ProfileImageEmpty")
@State non-public var ref: Picture = Picture("ProfileImageEmpty")

var physique: some View {
VStack(alignment: .middle, spacing: 8) {
    PhotosPicker(choice: $avatarItem, matching: .photos) {
        ZStack(alignment: .middle) {
            avatarImage
                .resizable()
                .modifier(CoverImage())
            
            if avatarImage == ref {
                HStack(alignment: .middle, spacing: 8) {
                    Picture(systemName: "digicam")                              
                        .font(.system(measurement: 18, weight:.semibold))
                    Textual content("Add Picture")
                        .modifier(Subtitle())
                }
            }
        }
    }
    .background(.clear)
    .onChange(of: avatarItem) {
        Job {
            if let loaded = strive? await avatarItem?.loadTransferable(kind: Picture.self) {
                avatarImage = loaded
            } else {
                print("Failed")
            }
        }
    }
}
.body(maxWidth: .infinity)
}
}



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments