나는 autolayout
에 앞뒤로 뻗어있는 UIPickerView
이 storyboards
에 있습니다.UIPicker 위치를 기반으로 UILabel x 값을 동적으로 조정 하시겠습니까?
의 각 섹션 옆에 UILabel
을 추가하고 피커 섹션에서 일정한 10 px
을 유지하고 싶습니다.
는 지금은 너무 프로그램과 같이 할 시도하고있다 :
는var hourXVal = pickerWidth - 330.0
var minXVal = pickerWidth - 190.0
var secXVal = pickerWidth - 50.0
if(self.view.frame.width == 320)
{
hourXVal = pickerWidth - 250.0
minXVal = pickerWidth - 140.0
secXVal = pickerWidth - 35.0
}
else if(self.view.frame.width == 414)
{
hourXVal = pickerWidth - 330.0
minXVal = pickerWidth - 190.0
secXVal = pickerWidth - 50.0
}
let hourLabel = UILabel(frame: CGRect(x:hourXVal, y:88, width: 100, height:40))
let minuteLabel = UILabel(frame: CGRect(x:minXVal, y:88, width: 100, height:40))
let secondLabel = UILabel(frame: CGRect(x:secXVal, y:88, width: 100, height:40))
hourLabel.text = "Hours"
minuteLabel.text = "Minutes"
secondLabel.text = "Sec"
self.timePickerView.addSubview(hourLabel)
self.timePickerView.addSubview(minuteLabel)
self.timePickerView.addSubview(secondLabel)
그러나, self.view.frame.width
는 잘 보이는 반면 6 UI에 대한이 (그래서 나타나도 불구하고 iPhone SE
및 iPhone 6
에 대해 동일한 폭을보고 SE를, 5)에 :
이 할 수있는 더 좋은 방법이 있나요? 방법?