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坐标大值

 

  

 

posted @ 2020-04-15 14:52  张亚楠  阅读(404)  评论(0编辑  收藏  举报