Last active
November 16, 2017 17:19
-
-
Save igiagante-zz/2161a55d04a7ebe8ca39144cf895d16a to your computer and use it in GitHub Desktop.
modal cupon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIViewController *vc = [[UIViewController alloc] init]; | |
UIView *superview = vc.view; | |
// Width constraint | |
[superview addConstraint:[NSLayoutConstraint constraintWithItem: superview | |
attribute:NSLayoutAttributeWidth | |
relatedBy:NSLayoutRelationEqual | |
toItem:nil | |
attribute: NSLayoutAttributeNotAnAttribute | |
multiplier:1 | |
constant:200]]; | |
// Height constraint | |
[superview addConstraint:[NSLayoutConstraint constraintWithItem: superview | |
attribute:NSLayoutAttributeHeight | |
relatedBy:NSLayoutRelationEqual | |
toItem:nil | |
attribute: NSLayoutAttributeNotAnAttribute | |
multiplier:1 | |
constant:200]]; | |
MLTitledSingleLineTextField * textField = [[MLTitledSingleLineTextField alloc]init]; | |
textField.placeholder = @"25OFFV"; | |
textField.title = @"un título"; | |
textField.backgroundColor = [UIColor ml_meli_dark_grey]; | |
[superview addSubview:textField]; | |
// Width constraint | |
[textField addConstraint:[NSLayoutConstraint constraintWithItem: textField | |
attribute:NSLayoutAttributeWidth | |
relatedBy:NSLayoutRelationEqual | |
toItem:nil | |
attribute: NSLayoutAttributeNotAnAttribute | |
multiplier:1 | |
constant:140]]; | |
// Height constraint | |
[textField addConstraint:[NSLayoutConstraint constraintWithItem: textField | |
attribute:NSLayoutAttributeHeight | |
relatedBy:NSLayoutRelationEqual | |
toItem:nil | |
attribute: NSLayoutAttributeNotAnAttribute | |
multiplier:1 | |
constant:30]]; | |
/* 2. Constraint to position label X*/ | |
NSLayoutConstraint *textFieldXConstraint = [NSLayoutConstraint | |
constraintWithItem: textField attribute:NSLayoutAttributeCenterX | |
relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:superview attribute: | |
NSLayoutAttributeCenterX multiplier:1.0 constant:60.0f]; | |
/* 3. Constraint to position label Y*/ | |
NSLayoutConstraint *textFieldYConstraint = [NSLayoutConstraint | |
constraintWithItem: textField attribute:NSLayoutAttributeCenterY | |
relatedBy:NSLayoutRelationEqual toItem:superview attribute: | |
NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f]; | |
/* 4. Add the constraints to button's superview*/ | |
[superview addConstraints:@[textFieldXConstraint, | |
textFieldYConstraint]]; | |
void (^actionBlock)(void) = ^{ | |
NSLog(@"This is a block"); | |
}; | |
MLModal * modal = [MLModal showModalWithViewController:vc | |
title:@"Ingresar Cupón" actionTitle:@"continuar" actionBlock: actionBlock]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment