//拿到整个storyboard文件
UIStoryboard * sb = [UIStoryboard storyboardWithName:@"NewStoryboard" bundle:nil];
//拿到每一个界面/箭头指向的界面
UIViewController * vc = [sb instantiateInitialViewController];
页面跳转
// 拿到源视图控制器
UIViewController *svc = self.sourceViewController;
// 拿到目标视图控制器
UIViewController *dvc = self.destinationViewController;
//在界面跳转的时候这个方法会自动调用
//UIStoryboardSegue联系界面之间动画跳转的类
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"跳转界面 会被调用");
//destinationViewController 可以拿到目标界面
//用storyBorad这个界面存在 不需要我们再重新创建 只需要拿到相应的界面
GreenViewController *greenVC = segue.destinationViewController;
}
//self.storyboard 当前storyBorad文件
//instantiateViewControllerWithIdentifier 拿到当前storyBorad中具体的界面
// id在storyboard面板相应界面 设置Storyboard ID
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"grayVC"];
//frame 描述视图的位置和大小 --参考点是父视图的(0,0)点/左上角
//屏幕适配 需要拿到屏幕的宽高 计算视图的位置和大小
//AutoLayout 新的体系 用来描述视图的位置和大小
//参考物 可以是任意视图/任一点
//通常需要4个属性/4个约束 来确定以视图的位置和大小
//trail 距右侧 ---将图层拖到右侧空白区域
//bottom 距下
//leading 距左
//top 距顶
//center 水平/垂直居中
//width 宽 ---将图层拖到右侧自身区域
//height 高
//equal width 宽相等 --- 将图层拖到参考图层中
//equal height 高相等
//constant -- 约束值
//priority -- 优先级
//multiplier -- 倍数 比例
//相对于哪个图层设置约束就向那个图层上拖拽
//1.使用autolayout 确定一个视图的位置 必须需要至少一个参照物/参照视图
//2.黄色警告 当前视图的frame和约束不一致 解决方法 更新frame 或更新约束
//3.红色警告 缺少约束或者多约束 即使少了约束程勋也不会影响程序运行,条件不够 视图在某种情况下很容易发生位置的变化 所以应该将约束设置全
//约束条件也可以拖进代码区 进行变化赋值
//改变约束的方法
-(void)viewDidLayoutSubviews{
//constant 约束的值
//self.width.constant = 100;
self.height.constant = 50;
[UIView animateWithDuration:2.0 animations:^{
//改变约束的值 需要调用这个方法
[self.view layoutIfNeeded];
}];
}