您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页iOS应用框架之-storyboard、动画效果

iOS应用框架之-storyboard、动画效果

来源:二三四教育网

iOS应用框架之-storyboard、动画效果

storyboard

  • 删除 main.storyboard, launchScreen.xib

    • Development Info > Main Interface置空
    • App Icon and Launch Images中,Launch Screen File置空,这个是iOS8以后增加的。
  • 在AppDelegate中添加如下代码后,得到一个320*480的白色框

    • Launch Screen Fie置空后,需要指定Luanch Images Source
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
  • 新建:controllers
  • 新建:storyboard, 添加控件
    • 当navigationBar、tabBar没有显示的时候,要设置
      • Top Bar
      • Bottom Bar
    • NavigationController, 设置成 Is Initial View Controller
    • AppDelegate.m中loadMainFrame如下
    - (void)loadMainFrame
    {
        UIStoryboard *storyBoard
        = [UIStoryboard storyboardWithName:@"User"
                                bundle:[NSBundle mainBundle]];
    
        UINavigationController *nav = storyBoard.instantiateInitialViewController;
        self.window.rootViewController = nav;
    }
  • 建立控件与代码之间的关联
    • 给xib指定class
    • 建立button/label与代码间的关联

IBOutlet, 关键字,指有能力与xib中某个变量关联

自动布局

适应不同的屏幕尺寸

方法

  • 在storyboard中选中控件
  • 在右下角选中第二个, Pin
  • 设置约束关系
  • 选中Align,设置对齐样式

动画效果

[self.window addSubview:self.loginNavigationVC.view];

[UIView animateWithDuration:2 //2s
                 animations:^{
                     self.loginNavigationVC.view.alpha = 0;
                     self.loginNavigationVC.view.frame = CGRectZero;
                     self.loginNavigationVC.view.transform = CGAffineTransformMakeScale(0.1, 0.1);
                 }
                 completion:^(BOOL finished) {
                     self.loginNavigationVC = nil;
                 }];

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务