// // BrandHeader.swift // Foxtronic // // import SwiftUI public struct BrandHeader:…
- User
// // BrandHeader.swift // Foxtronic // //
import SwiftUI
public struct BrandHeader: View { var imageName: String
codepublic enum HeaderSize: Double, CaseIterable { case standard = 200 case reduced = 100 } var headerSize: HeaderSize public init(imageName: String = "pilt", size: HeaderSize = .standard) { self.imageName = imageName self.headerSize = size } public var body: some View { GeometryReader { geometry in Image(imageName) .resizable() // Make the image resizable. .scaledToFill() // Fill the area while preserving the image’s aspect ratio. .frame(width: geometry.size.width, height: self.headerSize.rawValue * 1.25) // Adjust the height to achieve the bleed effect. .clipped() // Ensure that the image does not overflow the frame. .padding(.top, -50 * self.headerSize.rawValue / 200) // Adjusted based on header size to maintain consistency. } .frame(height: headerSize.rawValue) // Specify the overall height of the BrandHeader view. }}
// MARK: - Previews
struct BrandHeader_Previews: PreviewProvider { static var previews: some View { ScrollView { BrandHeader(imageName: "pilt", size: .standard) } .background(Color.gray) // Added a background color to visualize the bleed effect more clearly in preview. .edgesIgnoringSafeArea(.top) // Ensure preview simulates bleeding over the top safe area .previewDisplayName("Full Size") } }
Help me adjust the image a little bit higher, but keeping the frame as is
- Assistant
To adjust the position of the image a bit higher within its frame while keeping the frame dimensions unchanged, you'll need to apply an offset to the image. Using negative values for the parameter of the modifier will move the image upwards. Since you want to keep the height and appearance of the frame unchanged, adding an offset won't require changes to the frame itself but will shift the image's position within it.
- User
it moved the frame as well. i only want to move the image inside the frame a bit
- Assistant
- User
- Assistant