0

How can I hide a button for a particular device?

I want to hide one button only on iPhone 5s and iPhone SE because the button is superimposed on another one.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    Check [this](https://stackoverflow.com/questions/11197509/how-to-get-device-make-and-model-on-ios) out. – Daniel Apr 04 '18 at 23:04

2 Answers2

0

Because you want to hide the button for same resolution device so just checking the resolution will also work for you as iPhone SE & iPhone 5s both are of same resolutions.

height = 568.0, width = 320.0

let IS_IPHONE_5s_OR_SE = (max(UIScreen.main.bounds.width, UIScreen.main.bounds.height) == 568.0)

Or more deeply you can check How to get device make and model on iOS?.

TheTiger
  • 13,264
  • 3
  • 57
  • 82
0

If you are using AutoLayout, then either programmatically use UITraitCollection or Size Classes in Interface Builder. This will make things much easier in the long term. iPhone X for example has a regular height in portrait and a compact width whereas the SE and 5s have a compact height. But in landscape they share compact height and width, because the notch then obstructs.

Traits can account for this and layouts based on the trait definitions will be more likely to function with future devices than constraints based on model or pixel dimensions, which will more likely need updating and revising when future devices are released.

sketchyTech
  • 5,746
  • 1
  • 33
  • 56