Programmatically Add CenterX/CenterY Constraints

前端 未结 7 758

I have a UITableViewController that doesn\'t display any sections if there is nothing to show. I\'ve added a label to indicate to the user that there is nothing to display w

7条回答
  •  忘掉有多难
    2020-11-29 18:55

    In Swift 5 it looks like this:

    label.translatesAutoresizingMaskIntoConstraints = false
    label.centerXAnchor.constraint(equalTo: vc.view.centerXAnchor).isActive = true
    label.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor).isActive = true
    

提交回复
热议问题