This is my code:
@IBOutlet var txtFirstName: MDCTextField!
var txtFirstNameController: MDCTextInputControllerOutlined?
override func viewDidLoad() {
txtFirstNameController = MDCTextInputControllerOutlined(textInput: txtFirstName)
}
I want to add shadow to the text field but I couldn't find out how, I am using MaterialComponents
I have mentioned all the ways that I have tested and their results here:
1st way:
class ShadowLayer : MDCTextField{
override class var layerClass: AnyClass {
return MDCShadowLayer.self
}
var shadowLayer: MDCShadowLayer {
return self.layer as! MDCShadowLayer
}
func setDefaultElevation() {
self.shadowLayer.elevation = .cardResting
}
}
2nd way:
extension MDCTextField {
func elevate(elevation: Double) {
self.backgroundColor = UIColor.white
self.layer.masksToBounds = false
self.layer.shadowColor = UIColor.black.cgColor
self.layer.shadowOffset = CGSize(width: 0, height: elevation)
self.layer.shadowRadius = CGFloat(elevation)
self.layer.shadowOpacity = 1
}
}
choose country -> 1st way, choose city-> 2nd way
what I want is the pic below: