-1

I am struggling with a basic beginners problem at the moment. My app should run on all the different iPhones. My problem right now is that my constraints are not really responsive.

Examples:

enter image description here enter image description here enter image description here

As you can see on the iPhone 11 everything looks perfectly fine but on the iPhone 6s it a bit messed up sometimes.

My question, is there an easy way to make my design responsive? Not just the constraints but also text (e.g. "Main Wishlist" in the 3rd picture).

By the way I am doing everything programmatically. Any help on this is appreciated :)

Chris
  • 1,828
  • 6
  • 40
  • 108
  • okay, the text problem can be done easily using Scaling Fonts Automatically, – Sanad Barjawi Jan 21 '20 at 20:22
  • 4
    Constraints _are_ "responsive". That is exactly what constraints are: responsive. If your interface is not coming out the way you want it, then your constraints are wrong (for your purposes). Unfortunately, "it a bit mess up sometimes" is not descriptive, and we have no idea what your constraints are or what you wanted the interface to look like on the iPhone 6s, so it's impossible to help. – matt Jan 21 '20 at 20:23
  • 1
    Your design is responsive and "on the iPhone 6s it a bit messed up sometimes." is subjective. Imagine you are going to ask a developer to create an app with design defined with iPhone X. At the moment of validation of the project you say that the app is not responsive as you wished on iPhone 8 and iPhone 11 Max. You have to explicitly define a design by saying how layout is behaving on a different screen sizes to be able to say that something is not working as you wished. – Blazej SLEBODA Jan 21 '20 at 20:44

1 Answers1

1
  • Using the Dynamic Type you can solve the dynamic font problem

Here is an example of how you can scale your Fonts Automatically based on the content size using the Dynamic Type:

guard let customFont = UIFont(name: "CustomFont-Light", size: UIFont.labelFontSize) else {
    fatalError("""
        Failed to load the "CustomFont-Light" font.
        Make sure the font file is included in the project and the font name is spelled correctly.
        """
    )
}
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: customFont)
label.adjustsFontForContentSizeCategory = true

https://developer.apple.com/documentation/uikit/uifont/scaling_fonts_automatically

Sanad Barjawi
  • 539
  • 4
  • 15