I have an iOS app that places an image at a vertical position that is relative to wherever a particular input slider is placed, which can vary depending on the phone and the safe area at the top. The code works fine except on iPhone X.
Here's how I get the vertical position of the slider and then calculate the y position of the image based on my "rate" variable.
var zeroVert = Int(slider8.center.y)
var vertical: Int = zeroVert - 6 - Int(rate*20)
How do I programmatically adjust this for the safe area?
[update] I just now tried to get the safe area inset (using iPhone Xs max simulator), but it returns zero.
if #available(iOS 11.0, *) {
insetTop = Int(view.safeAreaInsets.top)
}
[update 2] Now that I think of it, I shouldn't care about the safe area margin as long as the position of the slider is known correctly. The image is just offset from that. So my problem is that I can't seem to fetch the proper position of the slider.