我有这个滑块,它在我的所有设备中都正确定位,除了我的iPad Pro。我使用下面的代码为我的iPhone和iPad设置滑块,但在Pro上定位已关闭。我该如何解决?
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
let scaleFactor = UIScreen.mainScreen().bounds.width / 320
let scaleFactor2 = UIScreen.mainScreen().bounds.height / 480
middleSlider = UISlider(frame: CGRectMake(120 * scaleFactor, 25, 150, 50))
middleSlider.tintColor = UIColor.whiteColor()
middleSlider.minimumTrackTintColor = UIColor.whiteColor()
middleSlider.maximumTrackTintColor = UIColor.whiteColor()
middleSlider.setThumbImage(UIImage(named: "thumb3"), forState: UIControlState.Normal)
middleSlider.maximumValue = 2.0
middleSlider.minimumValue = 0.0
middleSlider.value = 1.0
middleSlider.continuous = true
middleSlider.userInteractionEnabled = false
self.view?.addSubview(middleSlider)
}
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
let scaleFactor = UIScreen.mainScreen().bounds.width / 320
let scaleFactor2 = UIScreen.mainScreen().bounds.height / 480
middleSlider = UISlider(frame: CGRectMake(110 * scaleFactor, 50, 300, 150))
middleSlider.tintColor = UIColor.whiteColor()
middleSlider.setThumbImage(UIImage(named: "thumb3"), forState: UIControlState.Normal)
middleSlider.minimumTrackTintColor = UIColor.whiteColor()
middleSlider.maximumTrackTintColor = UIColor.whiteColor()
middleSlider.maximumValue = 2.0
middleSlider.minimumValue = 0.0
middleSlider.value = 1.0
middleSlider.continuous = true
middleSlider.userInteractionEnabled = false
self.view?.addSubview(middleSlider)
}