在我的ios应用程序中,即使在viewDidLoad()函数中指定了一些坐标,段控件也会根据故事板设置自己。
覆盖func viewDidLoad(){ super.viewDidLoad()
changeBackground()
changeBackground2()
trainSearchView.layer.cornerRadius = 12
passengerCheckinView.layer.cornerRadius = 12
trainsStatusVIew.layer.cornerRadius = 12
trainFrom.hidden = true
trainTo.hidden = true
trainNumber.hidden = true
trainName.hidden = false
activityIndicator.hidden = true
daySelector.addE
dispatch_async(dispatch_get_main_queue()){
self.radioTrainNumber.frame = CGRectMake(self.betweenStation.frame.origin.x, self.betweenStation.frame.origin.y + 40, self.radioTrainNumber.frame.size.width, self.radioTrainNumber.frame.size.height)
self.radioTrainName.frame = CGRectMake(self.radioTrainNumber.frame.origin.x, self.radioTrainNumber.frame.origin.y + 40, self.radioTrainName.frame.size.width, self.radioTrainName.frame.size.height)
self.trainName.frame = CGRectMake(self.trainFrom.frame.origin.x, self.radioTrainName.frame.origin.y + 40, self.trainName.frame.size.width, self.trainName.frame.size.height)
self.daySelector.frame = CGRectMake(self.daySelector.frame.origin.x, self.trainName.frame.origin.y + 55, self.daySelector.frame.size.width, self.daySelector.frame.size.height)
self.searchButton.frame = CGRectMake(self.searchButton.frame.origin.x, self.daySelector.frame.origin.y + 55, self.searchButton.frame.size.width, self.searchButton.frame.size.height)
let borderTrainSearch = UIView()
borderTrainSearch.frame = CGRect(x: self.trainSearchLabel.frame.origin.x + self.trainSearchLabel.frame.size.width, y: self.trainSearchLabel.frame.origin.y, width: 5,height: self.trainSearchView.frame.size.height )
borderTrainSearch.backgroundColor = UIColor.blackColor()
}
}
@IBAction func dayChanged(sender:UISegmentedControl){
if flagForRadioPosition {
daySelector.frame = CGRectMake(daySelector.frame.origin.x, radioTrainName.frame.origin.y + 55, daySelector.frame.size.width, daySelector.frame.size.height)
}
else {
self.daySelector.frame = CGRectMake(self.daySelector.frame.origin.x, self.trainName.frame.origin.y + 60, self.daySelector.frame.size.width, self.daySelector.frame.size.height)
}
}
答案 0 :(得分:0)
以上原因是与故事板的某种联系。但是我通过以编程方式创建段控件来避免这种情况,并且它正常工作