I know this questions has been asked multiple times, but I have followed most of the links in stack overflow but no answer seems to work. Also I saw somewhere that only 3 heights are allowed that too are above 160 which I don't want in my case. So please suggest a workaround
This are the codes I have tried
//this label doesn't matter
let classLabel: UILabel = {
let label = UILabel()
label.text = "Select Class"
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
//first try
var classPicker = UIPickerView(frame: CGRect(x: 0.0, y: 0.0, width:
30.0, height: 30.0))
//second try
var classPicker: UIPickerView = {
let picker = UIPickerView(frame: CGRect(x: 0.0, y: 0.0, width: 10.0, height: 10.0))
picker.translatesAutoresizingMaskIntoConstraints = false
return picker
}()
//third
lazy var chooseClass: UIStackView = {
classPicker.clipsToBounds = true
classPicker.heightAnchor.constraint(equalToConstant: 30.0)
let stackView: UIStackView = UIStackView(arrangedSubviews: [self.classLabel, self.classPicker])
stackView.axis = .horizontal
stackView.distribution = .fillEqually
stackView.alignment = .fill
stackView.spacing = 10.0
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()
//and then
chooseClass.heightAnchor.constraint(equalToConstant: 30.0)
Also I have tried answers from this link but it didn't work How to change UIPickerView height