create dropdown using materialdesign in swift iOS
Solution:
You can achieve the dropdown as like below.
1.First you have to create an imageview with dropdown arrow
2.Then after create textfield using material design pattern
3.Set the imageview as trailing view to the textfield then set the trailing view mode as always
4.Below code we can set the dropdown as well as field required symbol as placeholder also image tint color.Finally we can set the height of textfield and placeholder color
let dropdownImage = UIImageView()
dropdownImage.image = UIImage(named: "arrow_down_black_24pt")
dropdownImage.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
let tf = MDCOutlinedTextField()
tf.frame = CGRect(x: 10, y: 10, width: 200, height: 50)
tf.label.text = required == 1 ? placeHolder.appending("*") : placeHolder
tf.trailingView = dropdownImage
tf.trailingViewMode = .always
tf.trailingView?.tintColor = .black
tf.verticalDensity = 40
tf.setNormalLabelColor(.lightGray, for: .normal)
Comments
Post a Comment