Posts

Showing posts with the label nslayoutconstraint

How to center table footer view in container programmatically using NSLayoutConstraint?

How to center table footer view in container programmatically using NSLayoutConstraint? I am building a screen for an app which has favorites. This screen will display the list of items that a user has favorited. This list is going to be displayed in a table view, pretty vanilla stuff. I am trying to add a little code for the empty state of the list, when no favorites have been added yet. I'd like to put a UIView in the tableFooter and then put a UILabel in the center of that view. I want the view to take up all the available space within the screen. UIView tableFooter UILabel So far this is what I have: self.tableView.tableFooterView = buildTableViewFooter() Pretty self-explanatory. func buildTableViewFooter() -> UIView { let footer = UIView(frame: self.tableView.frame) let label = UILabel() label.text = "Use the heart icon to add favorites" label.font = UIFont.italicSystemFont(ofSize: 21.0) label.textColor = UIColor.lightGray label.textAlignment = .cen...