Просмотр прокрутки толкает элементы в верхнюю часть экранаIOS

Программируем под IOS
Ответить Пред. темаСлед. тема
Anonymous
 Просмотр прокрутки толкает элементы в верхнюю часть экрана

Сообщение Anonymous »

На мой взгляд, у меня есть изображение, с которым я всегда отображается, и какой -то текст под ним, который должен быть вертикально прокручивать. Этот текст может быть коротким или длинным. сверху, поэтому текст может получить больше места. верхняя часть экрана.

Код: Выделить всё

struct ContentView: View {
let longText: String = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."

let shortText: String = "This is short text"

var body: some View {
VStack {
Image(systemName: "photo").resizable().aspectRatio(contentMode: .fit).frame(width: 30, height: 20)

/// Note: This shows both elements image and text in the center of the view.
//            Text(shortText).font(.body)
//                .foregroundStyle(Color.primary)
//                .multilineTextAlignment(.center)
//                .padding(.top, 20.0)
//                .padding([.leading, .trailing], 25.0)

/// Note: Scrollview pushes the image and text on top.
ScrollView(showsIndicators: false) {
Text(shortText).font(.body)
.foregroundStyle(Color.primary)
.multilineTextAlignment(.center)
.padding(.top, 20.0)
.padding([.leading, .trailing], 25.0)
}
}
.padding(.top, 20.0)
}
}
короткий текст без просмотра прокрутки (это то, что я хочу, чтобы представление всегда искало короткий текст, то есть даже при представлении прокрутки):

Так выглядит представление в настоящее время с просмотром прокрутки и коротким текстом (я хочу, чтобы изображение и текст были центрированы так же, как и изображение выше, даже когда присутствует просмотр прокрутки) < /p>

Просмотр с изображением и длинным текстом (это, как и ожидалось, когда присутствует длинный текст)

Как я могу сохранить изображение и текстовый центр для более мелких текстов даже при просмотре прокрутки? Или есть другой способ достичь того, что я хочу?

Подробнее здесь: https://stackoverflow.com/questions/793 ... the-screen
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «IOS»