Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I've been trying to get scaling text(sized to fit it's container without trailing) into my views with the following modifiers below is the custom button code, and the image is it's containing view. I've applied the following modifiers to the button, but they seem to have no effect. Any guidance is much appreciated! Thank you for your time <3


Screen Shot 2022 10 21 at 7 42 52 AM — Postimages[^]

What I have tried:

.frame(maxWidth: .infinity)
.padding(.trailing, 20)
.foregroundColor(.white)
.font(.system(size: 25))
.lineLimit(1)
.minimumScaleFactor(0.1)
.fixedSize(horizontal: false, vertical: true)

struct ParkButton: View {
    @StateObject var config: ParkButtonConfig
    @Binding var isUserParkedHere: Bool
    var roadSide: RoadSide?

    init(operationQueue: OperationQueue, roadSide: RoadSide?, isUserParkedHere: Binding<Bool>) {
        _config = StateObject(
            wrappedValue:
                ParkButtonConfig(operationQueue: operationQueue)

                )

        self.roadSide = roadSide
        self._isUserParkedHere = isUserParkedHere
    }

    var body: some View {
        GeometryReader { g in
            Button {
                isUserParkedHere.toggle()
                config.detailViewDidSelectPark(roadSide: roadSide)
            } label: {
                Text(isUserParkedHere ?
                     LocalizedStrings.parkButtonSelectedTitle :
                        LocalizedStrings.parkButtonTitle)

                .background(
                    RoundedRectangle(cornerRadius: 5)
                        .stroke(Color.white, lineWidth: 1)
                )
        }
            //.frame(minWidth: g.size.width / 3 , maxWidth: .infinity, alignment: .leading)
        }
    }
       
}
Posted
Updated 21-Oct-22 2:26am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900