label showing top of screen instead of being on the inputAccessoryView

后端 未结 2 452
情歌与酒
情歌与酒 2021-01-24 03:49

Here is my code:

 var messageView : UITextView = {
        var textView = UITextView()
        textView.text = \"   Add your message here\"
        textView.text         


        
2条回答
  •  悲哀的现实
    2021-01-24 04:35

    You need to set translatesAutoresizingMaskIntoConstraints on the label to false and isActive to true on the constraints. Basically your constrains code should look like this:

    accessoryView.leadingAnchor.constraintEqualToAnchor(label.leadingAnchor, constant: 18).isActive = true
    accessoryView.centerYAnchor.constraintEqualToAnchor(label.centerYAnchor).isActive = true
    

提交回复
热议问题