Я приложил два изображения: первый — на iPhone XS Max, и я хочу, чтобы он выглядел так на всех устройствах. Второй — на iPhone 11.
Здесь я прикреплю свой код.
Код: Выделить всё
import SwiftUI
import AVFoundation
// Model
class PostItem: ObservableObject, Identifiable {
@Published var item: String = ""
}
// ViewModel
class ProfileViewModel: ObservableObject {
@Published var offerImages: [UIImage] = [UIImage(named: "AppIcon")!, UIImage(named: "AppIcon")!, UIImage(named: "AppIcon")!]
@Published var posts: [PostItem] = []
@Published var profession: String = "Profession"
@Published var bio: String = "Bio"
@Published var bi: String = "BI"
@Published var bioText: String = "Bio text"
@Published var proText: String = "Pro text"
@Published var biText: String = "BI text"
@Published var currentImageIndex: Int = 0
private var player: AVAudioPlayer!
private var timer: Timer?
init() {
for _ in 0.. some View {
configuration.label
.scaleEffect(configuration.isPressed ? 0.95 : 1.0)
.padding()
.frame(width: 100, height: 50)
.background(
Image("gradient 1")
.resizable()
.scaledToFill()
)
.foregroundColor(.white)
.cornerRadius(8)
.offset(x: 0, y: -100)
}
}
// Custom Collection View
struct CollectionView: View {
var images: [UIImage]
@Binding var currentIndex: Int
var body: some View {
GeometryReader { geometry in
ZStack {
ForEach(0..
Подробнее здесь: [url]https://stackoverflow.com/questions/78745070/swiftui-doesnt-look-the-same-on-all-devices[/url]
Мобильная версия