ios - Apply same vertical position as sibling view with autolayout -


class = "text">

I am creating a custom UITableViewCell , but I do not think it makes a difference - My question stands alone

I'm adding a scene, subclassing one of the existing cell styles, and a scene in the Superclass (a UILabel ) that is within the cell Adjusts its vertical position, depending on whether the content in other labels is present or not. If the second label contains content, the first label is centered vertically between the second label and the top of the cell view. If there is no content in the second label, the first label is centered between the upper and the bottom of the vertical panel view.

I like this behavior. I'm trying to add a third label horizontally horizontally to the first label, I have used the lack of autoletech to pin a new label that I have previously labeled like:

 < Code> [Visual format with NSLUET content restrictions: @ "[first label] - (5) - [third label]" option: 0 metric: zero view: view];  

This is working fine, but I can not understand how to do something with vertical position. Ideally, I'll always be in the same vertical alignment as the first label to "pin" the third label, whatever it may be, but I do not know how to express it in the visual form language.

As an alternative, firstly found out how to repeat the label's behavior (adjusting its vertical alignment based on appearance - or the lack of another label).

This barrier works correctly when the second label is is present, then vertically align the new label, but it does nothing if that particular cell The second label is empty:

  [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [third label] [second label]" option: 0 metric: zero view: view];  

How can I express the layout constraints?

visual format

vertical center alignment to create more complex layouts for you Trying, you NSLayoutConstraint of constraintwithItem: [...]. Method.

Here you can do:

  [NSLUET content restriction: with item: third label attribute: NSLayoutAttributeCenterY related: NSLayoutRelationEqual toItem: firstLabel attribute: NSLayoutAttributeCenterY multiplier: 1 constant : 0];  

Hope this helps,


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -