- Как я могу добавить
bestChoiceImage
в центре расстояния под ratingLabel
и rateButton
? - Почему, когда я использую
print(anysubview.center.x)
, это = 0,0, но в В симуляторе все остается на своих местах?
/ активировать вид изнутри Появится
let viewHeight = self.view.frame.height
let viewWidth = self.view.frame.width
NSLayoutConstraint.activate([
reebokClassic.topAnchor.constraint(equalTo: self.view.topAnchor, constant: viewHeight/12),
reebokClassic.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
modelName.topAnchor.constraint(equalTo: reebokClassic.bottomAnchor, constant: viewHeight/100),
modelName.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
sneakersImage.topAnchor.constraint(equalTo: modelName.bottomAnchor, constant: viewHeight/40),
sneakersImage.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
sneakersImage.widthAnchor.constraint(equalToConstant: viewWidth * 0.8),
sneakersImage.heightAnchor.constraint(equalToConstant: viewWidth * 0.8),
segmentedController.widthAnchor.constraint(equalToConstant: viewWidth),
segmentedController.topAnchor.constraint(equalTo: sneakersImage.bottomAnchor, constant: viewHeight/80),
segmentedController.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
segmentedController.heightAnchor.constraint(equalToConstant: viewHeight/23),
lastTimeWeared.topAnchor.constraint(equalTo: segmentedController.bottomAnchor, constant: viewHeight/40),
lastTimeWeared.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: viewHeight/100),
lastTimeWeared.widthAnchor.constraint(equalToConstant: viewWidth/3),
ratingLabel.topAnchor.constraint(equalTo: segmentedController.bottomAnchor, constant: viewHeight/40),
ratingLabel.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -viewHeight/50),
ratingLabel.widthAnchor.constraint(equalToConstant: viewWidth/3),
slipOnButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -viewHeight/20),
slipOnButton.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -viewWidth/20),
slipOnButton.widthAnchor.constraint(equalToConstant: viewWidth/5),
slipOnButton.heightAnchor.constraint(equalToConstant: viewHeight/20),
rateButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -viewHeight/20),
rateButton.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: viewWidth/20),
rateButton.widthAnchor.constraint(equalToConstant: viewWidth/5),
rateButton.heightAnchor.constraint(equalToConstant: viewHeight/20),
bestChoiceImage.widthAnchor.constraint(equalToConstant: viewWidth/3),
bestChoiceImage.heightAnchor.constraint(equalToConstant: viewWidth/3),
bestChoiceImage.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
bestChoiceImage.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant:
-(**rateButton.center.y - ratingLabel.center.y - bestChoiceImage.frame.height/2**))
])