-3

I am working on iOS design for iOS app ,but I have to use size class for each devices . Is there any way if I use one design which can be worked for other devices as well like android.

  • You need to look into Auto-Layout and using constraints to define your interface. – Upholder Of Truth Jan 30 '18 at 12:26
  • Thanks for reply.But in ipad designs it is very complicated.Are any standard available for it. – prachit patil Jan 30 '18 at 13:09
  • You can design some very complex interfaces using auto layout and it can simplify a lot of the process. You can define the constraints in Interface Builder, programatically or a combination. You can turn them on and off based on size classes and access them in code for finer tuning. I would suggest looking up the official documentation and some good tutorials. – Upholder Of Truth Jan 30 '18 at 13:44

2 Answers2

0

The answer will be very long for this. Let keep it short and sweet.

Explore Auto Layouts and Constraints.

No matter how big your app is, you will achieve it with auto layouts.

Pankaj Gaikar
  • 2,357
  • 1
  • 23
  • 29
0

Yes there is a way where you can design a app for IOS that will be worked for all other devices.

You have to set the layout and constraints programmatically.

Example -

 let exampleImageView: UIImageView = {
            let imageView = UIImageView(image: "Your Image Name")
            imageView.translatesAutoresizingMaskIntoConstraints = false
            imageView.contentMode = .scaleAspectFit
            return imageView
        }()

Then create a function and set the width, height etc

 func setLayout(){
                view.addSubview(exampleImageView)
                exampleImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
                exampleImageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
                exampleImageView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.5).isActive = true
    }

And finally why build a layout programmatically - because it will not break down in other devices for IOS app . For more you can follow this link- https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html

Rashed
  • 2,349
  • 11
  • 26
  • While there are times when you may need to build your constraints programmatically it's not absolutely needed to design interfaces to work across all devices. You can design some complex interfaces that look completely different all from within Interface Builder itself. Having said that auto layout, programmatically or otherwise, is the way to go. – Upholder Of Truth Jan 30 '18 at 13:42