• ios常用方法、基础语法总结


    一、常用方法:

         1、改变状态栏颜色

         2、 隐藏状态栏

         3、 控件显示到最上方

         4、 清除superView中的所有控件

         5、添加一个延迟任务:延迟一秒执行 nextQuestionOnclick方法

         6、创建一个提示框

         7、模型和字典赋值:必须保证属性名字和模型名字一致

         8、ViewController当控件被唤醒的时候加载:长做一些初始化操作

         9、  获取控件最最大的横坐标的值

    二、继承、分类

       1、改变状态栏颜色:

    - (UIStatusBarStyle)preferredStatusBarStyle{
       return UIStatusBarStyleLightContent;
    }
    

       2、隐藏状态栏:

    - (BOOL)prefersStatusBarHidden{
    return YES;
    }
    

       3、控件显示到最上方

    [self.view bringSubviewToFront:self._textTitle];
    

      

       4、清除superView中的所有控件

     [self.questionSelectView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    

       5、添加一个延迟任务:延迟一秒执行 nextQuestionOnclick方法

    [self performSelector:@selector(nextQuestionOnclick:) withObject:nil afterDelay:1];
    

      

       6、创建一个提示框

     UIAlertController *alertController= [UIAlertController alertControllerWithTitle:@"提示" message:@"恭喜你通关" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *okAlert=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
               
            }];
            [alertController addAction:okAlert];
            [self presentViewController:alertController animated:YES completion:nil];
    

      

        7、模型和字典赋值:必须保证属性名字和模型名字一致

     [self setValuesForKeysWithDictionary:dict];
    

      

        

    8、 ViewController当控件被唤醒的时候加载:长做一些初始化操作
    //当控件被唤醒的时候加载
    - (void)awakeFromNib{
     
    }

       

       9、  获取控件最最大的横坐标的值:

     CGRectGetMaxX(self.topBg.frame);//获取topBgX坐标大值

      

  • 相关阅读:
    QTdebug时没有调试引擎
    快速排序
    MFC之动态创建按钮
    Linux 本人常用到的基本命令
    history 查看历史操作记录在shell脚本执行中无法显示问题
    C#基础学习5
    C#基础学习4
    C#基础学习3
    C#基础学习1
    C#基础学习2
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/12705284.html
Copyright © 2020-2023  润新知