skip to Main Content
retweetButton.leadingAnchor.constraint(equalTo: replyButton.trailingAnchor, constant: actionSpacing),
        retweetButton.centerYAnchor.constraint(equalTo: replyButton), 

warning: Cannot convert value of type ‘UIButton’ to expected argument type ‘NSLayoutAnchor’

what’s problem

2

Answers


  1.   retweetButton.leadingAnchor.constraint(equalTo: replyButton.trailingAnchor, constant: actionSpacing)
        
    retweetButton.centerYAnchor.constraint(equalTo: replyButton.centerYAnchor)
    
    Login or Signup to reply.
  2. You need to provide an NSLayoutAnchor here. If you check equalTo parameter, it is expecting a NSLayoutAnchor

    retweetButton.centerYAnchor.constraint(equalTo: NSLayoutAnchor)

    you are passing a UIButton.
    That’s why it’s giving you the error and error description is simple and straight forward.

    Simply pass an NSLayoutAnchor accroding to your need where you want to place your button.
    Here in this case simply put centre Y anchor of replyButton error will go away. you can change this any anchor you want.

    retweetButton.centerYAnchor.constraint(equalTo: replyButton.centerYAnchor)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search