samedi 27 décembre 2014

How to add horizontal spacing and vertical spacing programmatically in ios?

I have created an app in ios 8. In that I have 4 labels which are available as vertically (it should change the position for certain conditions), I have disabled auto layout and setting constraints programmatically. Now, the problem is however I can set constraints for horizontal and vertical positions, width and height, I could not find any way to add constraints for horizontal and vertical spacing between the labels.


Can anyone please help me to do this.


So far I have the following code:



NSArray *constraint_V_WebUrl = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[weburl(31)]" options:0 metrics:nil views:contentDictionary];
NSArray *constraint_H_WebUrl = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[weburl(196)]" options:0 metrics:nil views:contentDictionary];
NSArray *constraint_POS_H_WebUrl = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-13-[weburl]" options:0 metrics:nil views:contentDictionary];
[self.cardDetails addConstraints:constraint_POS_V_WebUrl];
[self.cardDetails addConstraints:constraint_POS_H_WebUrl];
[self.cardDetails addConstraint:[NSLayoutConstraint constraintWithItem:self.weburl attribute:NSla relatedBy:NSLayoutRelationEqual toItem:self.cardDetails attribute:NSLayoutAttributeTopMargin multiplier:1 constant:0.0]];


Code above works fine. But I want to set horizontal and vertical spacing between the labels.




Aucun commentaire:

Enregistrer un commentaire