SwiftUI – How to set the title of a NavigationView to large title (or small)?

SwiftUI (iOS 14+) NavigationView { TopLevelView { // […] } .navigationBarTitleDisplayMode(.inline) // ⬅️ Important part } SwiftUI (Xcode 11.3) SwiftUI navigationBarTitle modifier has an optional displayMode property which you can set to .inline for small titles and .large for large titles. See documentation NavigationView { TopLevelView { // […] } .navigationBarTitle(“Test”, displayMode: .inline) // ⬅️ … Read more

Image full screen width in SwiftUI

The reason .aspectRatio(contentMode:) had no effect on the layout is because you did not make the image resizable with resizeable(). Doing var body: some View { Image(“page-under-construction”) .resizable() .aspectRatio(contentMode: .fill) } will cause the image to be the width of the screen, but the image’s aspect ratio will not be maintained. To maintain the aspect … Read more

How to round specific corners of a View?

Demo (Source code is available at the end of the post) iOS 16+ built-in modifier (Xcode 15 needed) Clip the view using the new UnevenRoundedRectangle: .clipShape( .rect( topLeadingRadius: 0, bottomLeadingRadius: 20, bottomTrailingRadius: 0, topTrailingRadius: 20 ) ) ⚠️ Note: Although it works from iOS 16, .rect needs Xcode 15 to be available. iOS 13+ You … Read more

Make ScrollView scrollable only if it exceeds the height of the window

For some reason I could not make work any of the above, but it did inspire me find a solution that did in my case. It’s not as flexible as others, but could easily be adapted to support both axes of scrolling. import SwiftUI struct OverflowContentViewModifier: ViewModifier { @State private var contentOverflow: Bool = false … Read more

Set the Navigation Bar Title Font

In SwiftUI, at this point we can not change the navigationBarTitle font directly, but you can change navigationBar appearance like this, struct YourView: View { init() { //Use this if NavigationBarTitle is with Large Font UINavigationBar.appearance().largeTitleTextAttributes = [.font : UIFont(name: “Georgia-Bold”, size: 20)!] //Use this if NavigationBarTitle is with displayMode = .inline //UINavigationBar.appearance().titleTextAttributes = [.font … Read more

How to create a simple Binding for previews

You can use .constant(VALUE) in your Previews, no need to create a @State. /// A value and a means to mutate it. @propertyWrapper public struct Binding<Value> { /// Creates a binding with an immutable `value`. public static func constant(_ value: Value) -> Binding<Value> } e.g. TestView(someProperty: .constant(5.0))

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)