gpt4 book ai didi

SwiftUI : text gets cut off with "..." in my view

转载 作者:行者123 更新时间:2023-11-30 10:29:04 26 4
gpt4 key购买 nike

在我看来,我有很多文本和周围的边框,但有时会被切断并在末尾有“...”。我尝试过 .layout .layoutPriority().fixedSize() ,奇怪的是,这取决于我使用 .layoutPriority() 的位置和频率。它不会在每个设备上的同一位置被切断。 Screenshot of it in the iPhone 8 iOS 13.3 simulator 。预先感谢您的帮助。

这是我当前的代码

import SwiftUI
import SafariServices

struct WhatIsStopView: View {

@State var show4 = false

var body: some View {
GeometryReader { geometry in
ScrollView(.vertical) {
VStack(alignment: .leading, spacing: 30) {
HStack(spacing: 15) {
Text("whatIsAStop")
Image(systemName: "camera")
}.font(.largeTitle)
VStack(alignment: .leading, spacing: 45) {
VStack(alignment: .leading, spacing: 25) {
Text("inPhotographyAStop").layoutPriority(2)

Text("stopDoubling").fontWeight(.semibold).layoutPriority(2)

Text("forExample").layoutPriority(2)

VStack {
Image("exposure-stops").resizable()
.aspectRatio(contentMode: .fit)
Text("stopIsAMeasure").italic().layoutPriority(2)
}

Text("amountOfLightCaptured").layoutPriority(2)

}

VStack(alignment: .leading, spacing: 25) {
Text("stopsAndShutterSpeed").font(.headline).layoutPriority(2)

Text("shutterSpeedMeasures").layoutPriority(2)

VStack {
Image("exposure-stops-shutter-speed").resizable()
.aspectRatio(contentMode: .fit)
Text("commonShutterSpeedStops").italic().layoutPriority(2)
}

Text("forExampleChanging").layoutPriority(2)

Text("mostCamerasAllow").layoutPriority(2)
}

VStack(alignment: .leading, spacing: 25) {
Text("stopsAndISOSpeed").font(.headline).layoutPriority(2)

Text("ISOSpeedDescribes").layoutPriority(2)

VStack {
Image("exposure-stops-iso-speed").resizable()
.aspectRatio(contentMode: .fit)
Text("commonISOSpeedStops").italic().layoutPriority(2)
}

Text("ISOIsMeasured").layoutPriority(2)

Text("forExampleSwitching").layoutPriority(2)
}

VStack(alignment: .leading, spacing: 25) {
Text("stopsAndAperture").font(.headline).layoutPriority(2)

Text("apertureIsMeasured").layoutPriority(2)

VStack {
Image("exposure-stops-aperture").resizable()
.aspectRatio(contentMode: .fit)
Text("commonApertureStops").italic().layoutPriority(2)
}

Text("becauseOfTheWay").layoutPriority(2)

Text("asWithShutterSpeed").layoutPriority(2)
}

VStack(alignment: .leading, spacing: 25) {

Text("stopsAreInterchangeable").font(.headline).layoutPriority(2)

Text("theGreatThing").layoutPriority(2)

Text("letsSay").layoutPriority(2)

Text("thisChangeOf").layoutPriority(2)

Text("youCouldOpen").layoutPriority(2)

Text("alternativelyYouCould").layoutPriority(2)

Text("asYouCanSee").layoutPriority(2)
}

VStack(alignment: .leading, spacing: 25) {

Text("conderationsWhenAdjustingExposure").font(.headline).layoutPriority(2)

Text("whenAdjustingTheThree").layoutPriority(2)

Text("shutterSpeedIf").layoutPriority(2)

Text("apertureA").layoutPriority(2)

Text("ISOSpeedThe").layoutPriority(2)

Text("asWithEverything").layoutPriority(2)

Text("exposureStopsAreA").layoutPriority(2)
}

Divider()

HStack {
Button(action: {
self.show4.toggle()
}) {
Text("linkToOriginalArticle").padding().foregroundColor(.white)
.background(LinearGradient(gradient: .init(colors: [.yellow,.purple]), startPoint: .leading, endPoint: .trailing))
.cornerRadius(20)
.sheet(isPresented: self.$show4) {
photography().edgesIgnoringSafeArea(.all)
}
}
Spacer()
Text("© Photography Mad")
}

}.padding()
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke((LinearGradient(gradient: .init(colors: [.purple,.blue]), startPoint: .leading, endPoint: .trailing)), lineWidth: 4)
)
Spacer()
}.padding()
VStack {
AdView().frame(width: 320, height: 50)
}.edgesIgnoringSafeArea([.top, .leading, .trailing])
}
}
.navigationBarTitle(Text("whatIsAStop"), displayMode: .inline)
}
}

struct WhatIsStopView_Previews: PreviewProvider {
static var previews: some View {
WhatIsStopView()
.environment(\.locale, .init(identifier: "fr"))
}
}


struct photography : UIViewControllerRepresentable {

func makeUIViewController(context: UIViewControllerRepresentableContext<photography>) -> SFSafariViewController {
let controller = SFSafariViewController(url: URL(string: "https://www.photographymad.com/pages/view/what-is-a-stop-of-exposure-in-photography")!)
return controller
}
func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<photography>) {

}
}

最佳答案

在 iOS 14 中你可以尝试

对于水平扩展尝试

.fixedSize(horizontal: false, vertical: true)

对于垂直扩展尝试

.fixedSize(horizontal: true, vertical: false)

关于SwiftUI : text gets cut off with "..." in my view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59514310/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com