Reputation: 55
I have created a tableview with dynamic cells. I have added a label in a cell.
The label is always placed in centre of the cell.
I don't want it to be dynamically placed when I adjust the height of the row.
I would like to place the label 20px under the top of the cell.
How can I do this?
Upvotes: 0
Views: 1042
Reputation: 1651
If using Auto Layouts, give these 4 constraints, it will work.
Drop the label on custom cell where exactly you want, give top space, tailing and leading and also a fixed height.
Upvotes: 0
Reputation: 73
Use Auto Layouts in your StoryBoard. Like these
You have to setup all the constraints in the storyboard to make it work properly.
Upvotes: 1
Reputation: 1
If you use autolayout, set constraint.
Select label and Drag to upper of label by pushing control.
When popup appears, push option key.
Click "Top Space to Container"
Select label and look into size inspector. Modify constant value of "Top Space To" constraint to 20.
Upvotes: 0
Reputation: 27448
You can set constraints like top,leading,trailing and fixed height
to that label if you are using autolayout.
Put your label in cell with 20 pixel of distance from top and then set constraints or pin constraints as mentioned above.
Hope this will help :)
Upvotes: 1