/**
*
*/
UIView *viwe1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 120, 80)];
viwe1.backgroundColor = [UIColor redColor];
viwe1.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:viwe1];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(80, 200, 100, 60)];
view2.backgroundColor = [UIColor orangeColor];
view2.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:view2];
/**
* pppp
*/
NSLayoutConstraint *view1With = [NSLayoutConstraint constraintWithItem:viwe1 attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0 constant:150];
NSLayoutConstraint *view1Hight = [NSLayoutConstraint constraintWithItem:viwe1 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0 constant:150];
[viwe1 addConstraint:view1With];
[viwe1 addConstraint:view1Hight];
NSLayoutConstraint *view1OriginX = [NSLayoutConstraint constraintWithItem:viwe1 attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:20];
NSLayoutConstraint *view1OriginY = [NSLayoutConstraint constraintWithItem:viwe1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:100];
[self.view addConstraint:view1OriginX];
[self.view addConstraint:view1OriginY];
NSLayoutConstraint *with = [NSLayoutConstraint constraintWithItem:view2 attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0 constant:10];
[view2 addConstraint:with];
NSLayoutConstraint *higth = [NSLayoutConstraint constraintWithItem:view2 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0 constant:10];
[view2 addConstraint:higth];
NSLayoutConstraint *originX = [NSLayoutConstraint constraintWithItem:view2 attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:viwe1 attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0];
NSLayoutConstraint *originY = [NSLayoutConstraint constraintWithItem:view2 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:viwe1 attribute:NSLayoutAttributeBottom multiplier:1.0 constant:120];
[self.view addConstraint:originX];
[self.view addConstraint:originY];
凹凸累out
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 又到一年年底时,作为家庭主妇,我洗刷收拾得比平时更带劲儿了。 大旭幼儿园放假了,我又开始了每天带两个孩子的时光。还...
- There is no doubt that we should never go out there to se...
- 《欢乐颂2》结束了有一段时间了 但是曲筱绡在观众的脑海中 依然挥之不去 这样的一个妖精人物 却生不起我们对她的厌恶...