代码拉取完成,页面将自动刷新
//
// ViewController.m
// Layout代码
//
// Created by hyl on 16/5/16.
// Copyright © 2016年 hyl. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)viewDidLoad{
[super viewDidLoad];
self.view.translatesAutoresizingMaskIntoConstraints=NO;
UIView *viewRed=[[UIView alloc]init];
viewRed.backgroundColor=[UIColor redColor];
viewRed.translatesAutoresizingMaskIntoConstraints=NO;
[self.view addSubview:viewRed];
//viewRed.frame=CGRectMake(100, 100, 100, 50);
NSLayoutConstraint *widthConstraint=[NSLayoutConstraint constraintWithItem:viewRed attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:100];
[viewRed addConstraint:widthConstraint];
NSLayoutConstraint *heightConstraint=[NSLayoutConstraint constraintWithItem:viewRed attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:50];
[viewRed addConstraint:heightConstraint];
NSLayoutConstraint *leftContraint=[NSLayoutConstraint constraintWithItem:viewRed attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:30];
[self.view addConstraint:leftContraint];
NSLayoutConstraint *topConstraint=[NSLayoutConstraint constraintWithItem:viewRed attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:30];
[self.view addConstraint:topConstraint];
}
@end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。