Skip to content

Instantly share code, notes, and snippets.

View iltercengiz's full-sized avatar

Ilter Cengiz iltercengiz

View GitHub Profile
@iltercengiz
iltercengiz / Constraints.m
Last active August 29, 2015 14:18
Variable Bindings
NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[redView(==blueView)]-0-[blueView]-|"
options:0
metrics:nil
views:@{@"redView": redView,
@"blueView": blueView}];
[self.view addConstraints:constraints];
[self.titleLabel sizeToFit];
CGFloat titleLabelWidth = CGRectGetWidth(self.titleLabel.frame) + margin * 2; // margin from both sides.
CGFloat imageViewWidth = CGRectGetWidth(self.imageView.frame) + margin * 2; // margin from both sides.
CGFloat height = CGRectGetHeight(self.imageView.frame) + CGRectGetHeight(self.titleLabel.frame) + margin * 3; // margin from top and bottom and distance between `imageView` and `titleLabel`.
return CGSizeMake(MAX(titleLabelWidth, imageViewWidth), height);