iOS基础笔记

基于STM32的智能循迹小车设计(基础版) 基于STM32的智能循迹小车设计 硬件准备 1、小车底盘+四直流电机(带轮) 2、STM32F103C8T6核心板 3、12V 8700mAh锂电池(可以用几节18650锂电池) 4、循迹模块 选择的是TCRT500L,五路集成在一起,集成度比较高,但是可能不如五个单独的循迹模块好用 5、L298N电机驱动模块 四驱车为啥用L298N电机驱动模块? 可以把左边的两个电机并联,用输出A控制。把右边的两个电机并联,用输出B控制。 12V供电接电源正极,供电GND接电源负极和核心板GND,5V供电接核心 阅读详情
/**************UIView***************/
    //实例化一个UIView
    //frame:设置view的位置和大小  (0,0)屏幕的最左上角的点   X:正轴方向->向右 Y:正轴方向->向下
    UIView *view = [[UIView alloc] init];
   //设置位置和大小
    //1、frame方式
    view.frame = CGRectMake(50, 100, 220, 220);
//    view.frame = CGRectMake(CGFloat x(X:正轴方向->向右,view在x轴的方向), CGFloat y(Y:正轴方向->向下,view在y轴的方向), CGFloat width(view自己的宽), CGFloat height(view自己的高))
    //2、center和bounds组合的方式
    //找到中心点
    view1.center = CGPointMake(50+220/2, 100+220/2);
    //后两个参数是view自己的宽和高,前两个参数影响的是本身view的原点坐标,如果不理解,前两个参数就写0,0
    view1.bounds = CGRectMake(0, 0, 220, 220);
    //背景颜色的设置
    view.backgroundColor = [UIColor greenColor];
    //隐藏属性 hidden : BOOL  YES:隐藏   NO:不隐藏  默认不隐藏   //父视图对子视图的影响:父视图隐藏子视图跟着隐藏   //子视图对父视图的影响:没有影响
    view.hidden = NO;
    //透明度   //父视图对子视图的影响:父视图的透明度影响子视图的透明度   //子视图对父视图的影响:没有影响
    view.alpha = 1;
    //tag
    view.tag = 1333;
    //由tag值读取
    UIView *view2 = (UIView *)[self.window viewWithTag:1333];
    //子视图添加到父视图上   //子视图和父视图是一个相对的概念
    [self.window addSubview:view];//父视图写在前面,子视图写在后面
    /*******************圆角及阴影**********************/
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 100, 220, 220)];
    view.backgroundColor = [UIColor redColor];
    //设置圆角的角度
    view.layer.cornerRadius = 20;
    //设置边框的宽度,默认颜色为黑色
    view.layer.borderWidth = 4;
    //设置边框颜色
    view.layer.borderColor = [UIColor greenColor].CGColor;
    //YES:不显示边框以外的视图   NO:显示边框以外的视图(都是相对子视图来说的)  YES:阴影效果出不来
    view.layer.masksToBounds = NO;
    //阴影效果
    //设置阴影颜色
    view.layer.shadowColor = [UIColor grayColor].CGColor;
    //设置阴影移动角度
    view.layer.shadowOffset = CGSizeMake(100, 100);
    //设置阴影透明度,默认完全透明
    view.layer.shadowOpacity = 1;
    //设置阴影虚化角度
    view.layer.shadowRadius = 50;
    /*******************层次关系***********************/
    //移除某个视图
//    [view4 removeFromSuperview];
    //把某个视图移动到最上面
//    [self.view bringSubviewToFront:view1];
    //把某个视图移动到最下面
//    [self.view sendSubviewToBack:view1];
    //将某个视图插入到另一个视图的上面,前面的参数是想要移动到上面的视图
//    [self.view insertSubview:view2 aboveSubview:view3];
    //将某个视图插入到另一个视图的下面,前面的参数是想要移动到下面的视图
//    [self.view insertSubview:view2 belowSubview:view3];
    //将某个视图插入到指定的位置
//    [self.view insertSubview:view1 atIndex:2];
    //交换两个视图的位置
    [self.view exchangeSubviewAtIndex:2 withSubviewAtIndex:1];
    /*************父子视图之间的响应关系*****************/
    /*
     超出父视图的部分没有响应,子视图的响应范围在父视图的里面的范围
     */
//****可以打开用户响应的属性;YES:它上面的子视图有响应,NO:它上面的子视图无响应*****//
    label.userInteractionEnabled = YES;


/************UILabel*************/
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 70, 300, 100)];
    label.backgroundColor = [UIColor greenColor];
    label.hidden = NO;
    label.alpha = 1;
    //设置UILabel的文本文字
    label.text = @"这是一个UILabel,这是一个UILabel,这是一个UILabel,这是一个UILabel";
    //设置文本字体的颜色
    label.textColor = [UIColor orangeColor];
    //设置字体大小
    label.font = [UIFont systemFontOfSize:18.0];
    //字体加粗
    label.font = [UIFont boldSystemFontOfSize:18.0];
    //斜体
//    label.font = [UIFont italicSystemFontOfSize:18.0];
    //对齐方式
    /*
     1、NSTextAlignmentCenter  居中对齐
     2、NSTextAlignmentLeft    左对齐
     3、NSTextAlignmentRight   右对齐
     */
    label.textAlignment = NSTextAlignmentLeft;
    //行数  除0以外的数字是固定的行数  0:可以自动换行
    label.numberOfLines = 0;
   //自适应文字大小  YES:可以自适应   NO:不能自适应   (一般用在展示一行文字的情况下)
    label.adjustsFontSizeToFitWidth = YES;
    //自适应label文字高度
    [label sizeToFit];
    /*************自适应高度*****************/
    //实例化
    UILabel *label = [[UILabel alloc] init];
    //属性相关
    label.backgroundColor = [UIColor grayColor];
    label.textColor = [UIColor blackColor];
    label.textAlignment = NSTextAlignmentLeft;
    //文字
    NSString *labelStr = @"换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深换成了时空距离深";
    //字体
    UIFont *font = [UIFont systemFontOfSize:24.0];
    //字体字典
//    NSDictionary *fontDic = [NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil];
    NSDictionary *fontDic = @{NSFontAttributeName:font};
    //frame->CGRect->size
    CGRect labelRect = [labelStr boundingRectWithSize:CGSizeMake(300, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:fontDic context:nil];
      //这里写上面创建的字符串
//    CGRect labelRect = [labelStr
    //CGSize 第一个参数写想要创建的label的宽度   第二个参数写MAXFLOAT(这个参数的意思是苹果官方认定的最大值)
//   boundingRectWithSize:CGSizeMake(<#CGFloat width#>, <#CGFloat height#>)
    //options这里就写NSStringDrawingUsesLineFragmentOrigin
//   options:<#(NSStringDrawingOptions)#>
    //attributes里面写上面创建的字典
//   attributes:<#(NSDictionary *)#>
    //context里面写nil就可以
//   context:<#(NSStringDrawingContext *)#>]
    //由CGRect读取里面的size
    CGSize size = labelRect.size;
    //由size里读取height
    label.frame = CGRectMake(10, 30, 300, size.height);
    //自动换行
    label.numberOfLines = 0;
    //设置文本
    label.text = labelStr;
    //设置字体大小
    label.font = font;
    //CGRect->CGSize->height
    //添加
    [self.window addSubview:label];

    //全屏宽度:self.window.frame.size.width
    //全屏高度:self.window.frame.size.height

/***************UIButton(文字)********************/
//    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 30, 40, 20)];
    //最常用
    /*  UIButtonType
     1、UIButtonTypeSystem = UIButtonTypeRoundedRect 直角
     2、UIButtonTypeContactAdd 蓝色圆圈里面有加号
     3、UIButtonTypeDetailDisclosure = UIButtonTypeInfoDark = UIButtonTypeInfoLight  蓝色圆圈里面有叹号
     */
    //类方法创建
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    //属性设置:1、backgroundColor、文字等
    btn.frame = CGRectMake(10, 60, 300, 30);
    btn.backgroundColor = [UIColor redColor];
    //文字设置:用setTitle的方法
    /*
     1、UIControlStateNormal  正常状态
     2、UIControlStateHighlighted  高亮状态
     3、UIControlStateSelected   选中状态
     4、UIControlStateDisabled   禁用状态
     */
    [btn setTitle:@"我是按钮" forState:UIControlStateNormal];
    [btn setTitle:@"高亮" forState:UIControlStateHighlighted];
    [btn setTitle:@"点击" forState:UIControlStateSelected];
    [btn setTitle:@"禁用" forState:UIControlStateDisabled];
    //选中状态:默认为正常状态 默认为NO
    btn.selected = YES;
    //禁用状态:默认为YES  YES为可用状态,NO为不可用
    btn.enabled = YES;
    //设置文字的颜色(可更改四种状态)
    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor cyanColor] forState:UIControlStateDisabled];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
    [btn setTitleColor:[UIColor greenColor] forState:UIControlStateSelected];
    //设置文字的大小
    btn.titleLabel.font = [UIFont systemFontOfSize:18.0];
    //添加点击事件
    /*
     1、第一个参数是接受消息的对象,写self
     2、第二个参数是消息名称
     3、第三个参数是触发条件,一般就写UIControlEventTouchUpInside
     */
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    //添加到window层上
    [self.window addSubview:btn];
    /***************UIButton(图片)********************/
    //由图片名字找到图片,并实例化一个UIImage类
    UIImage *image = [UIImage imageNamed:@"1.png"];
    UIImage *image1 = [UIImage imageNamed:@"map.png"];
    //类方法创建图片类型的button   **注:后面的类型一定要选UIButtonTypeCustom
    UIButton *customBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    /*
     1、读取图片的宽度:image.size.width
     2、读取图片的高度:image.size.height
     */
//    customBtn.frame = CGRectMake(50, 150, image.size.width, image.size.height);
    customBtn.frame = CGRectMake(50, 150, 100, 50);
    customBtn.backgroundColor = [UIColor grayColor];
    //设置图片(可有四种状态)
    //按钮尺寸小于图片尺寸,图片会被压缩;按钮尺寸大于图片尺寸,图片以原尺寸显示
//    [customBtn setImage:image1 forState:UIControlStateNormal];
    //图片会随着按钮的尺寸进行拉伸或压缩
    [customBtn setBackgroundImage:image1 forState:UIControlStateNormal];
    //如果用custom类型,设置既有文字又有图片时,可有两种情况:1、整体按钮大小大于setImage时方法设置的图片的大小时,文字在图片右面显示;整体按钮大小小于setImage时方法设置的图片的大小时,文字bu显示;2、用setBackgroundImage设置图片时,文字居中显示
    [customBtn setTitle:@"button" forState:UIControlStateNormal];
    //不带参数的方法
//    [customBtn addTarget:self action:@selector(customCilck) forControlEvents:UIControlEventTouchUpInside];
    //带参数的方法,多了一个:
    [customBtn addTarget:self action:@selector(customDown:) forControlEvents:UIControlEventTouchUpInside];
    customBtn.tag = 1000;
    [self.window addSubview:customBtn];
//带参数的写法
- (void)customDown:(UIButton *)button{
    NSLog(@"%ld",(long)button.tag);
}
//不带参数的写法
- (void)btnClick{
    NSLog(@"btnClick");
}
//获取按钮的文字  :button.currentTitle


  //实例化一个UIViewController对象
    RootViewController *root = [[RootViewController alloc]init];
    //把root对象作为window的根视图
    self.window.rootViewController = root;

   /****************UIImageView*****************/
    //1、由名字直接读取图片
    //优点:效率高,读取图片时间较短
    //缺点:读取到之后,不会销毁,相对来说,消耗内存
    //由名字读取图片一般小图片用这个方法
    UIImage *image = [UIImage imageNamed:@"1.png"];
    //实例化
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 40, image.size.width, image.size.height)];
    //相关属性
    imageView.backgroundColor = [UIColor orangeColor];
    //添加图片的属性
    imageView.image = image;
    [self.view addSubview:imageView];
    
    //2、路径读取
   //优点:读取之后,图片销毁,不会消耗太多的内存
    //缺点:效率低,读取时间相对较长
    //由路径读取图片一般大图片用这个方法
    NSString *path = [[NSBundle mainBundle]pathForResource:@"map" ofType:@"png"];
    UIImage *image1 = [UIImage imageWithContentsOfFile:path];
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 80, 300, 380)];
    imageView1.image = image1;
    [self.view addSubview:imageView1];

 /***************UIImageView动画效果******************/
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 1; i<=12; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"player%d",i]];
        [array addObject:image];
    }
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 64, 64)];
    imageView.backgroundColor = [UIColor grayColor];
    imageView.userInteractionEnabled = YES;
    imageView.tag = 1000;
    //图片填充效果
    /*
     1、UIViewContentModeScaleToFill   拉伸填满
     2、UIViewContentModeScaleAspectFit   按比例填充
     3、UIViewContentModeScaleAspectFill  按比例填满
     */
    imageView.contentMode = UIViewContentModeScaleToFill;
    //设置动画图片(数组)
    imageView.animationImages = array;
    //设置每次循环的时间(秒)
    imageView.animationDuration = 1;
    //设置循环次数:0:无限循环  >0的数:循环几次结束
    imageView.animationRepeatCount = 0;
    [self.view addSubview:imageView];
    //开始动画
    [imageView startAnimating];
    //结束动画
    [imageView stopAnimating];

/****************UITextField******************/
    UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, (self.view.frame.size.height - 110), 300, 35)];
    textField.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:textField];
    //设置边框 (**)
    /*
     1、UITextBorderStyleNone  无边框
     2、UITextBorderStyleLine  直线直角
     3、UITextBorderStyleBezel   粗一点
     4、UITextBorderStyleRoundedRect  圆角
     */
    textField.borderStyle = UITextBorderStyleRoundedRect;
    //设置右下角return键的格式 (**)
    /*
     1、UIReturnKeyDefault  return
     2、UIReturnKeyJoin     Join
     3、UIReturnKeyNext     Next
     */
    textField.returnKeyType = UIReturnKeyNext;
    //键盘样式  (*)
    textField.keyboardType = UIKeyboardTypeDefault;
    //设置背景图片:只有UITextBorderStyle=UITextBorderStyleNone的时候才有效果
    textField.background = [UIImage imageNamed:@"restartServer@2x.png"];
    //设置清除按钮(右边的圆圈X号)(**)
    textField.clearButtonMode = UITextFieldViewModeAlways;
    //是否自动大写 (**)
    /*
     1、UITextAutocapitalizationTypeNone  不自动大写
     2、UITextAutocapitalizationTypeWords  单词的首字母大写
     3、UITextAutocapitalizationTypeSentences  句子的首字母大写
     4、UITextAutocapitalizationTypeAllCharacters  全部大写
     */
    textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    //自动纠错 (**)
    /*
     1、UITextAutocorrectionTypeDefault  默认
     2、UITextAutocorrectionTypeNo       不自动纠错
     3、UITextAutocorrectionTypeYes      自动纠错
     */
    textField.autocorrectionType = UITextAutocorrectionTypeDefault;
    //是否可编辑  YES:可以  NO:不可以
    textField.enabled = YES;
    //提示文字  (**)
    textField.placeholder = @"请输入。。。";
    //文字颜色
    textField.textColor = [UIColor orangeColor];
    //默认文字  (**)
    textField.text = @"wenzi";
    //字体大小  (**)
//    textField.font = [UIFont systemFontOfSize:18.0];
    //对齐方式(左右)(**)
    textField.textAlignment = NSTextAlignmentCenter;
    //对齐方式(上下)
    textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    //密文  (**)
    textField.secureTextEntry = NO;
    //再次编辑清空文字  (*)
//    textField.clearsOnBeginEditing = YES;
    //字体适配输入框大小
    textField.adjustsFontSizeToFitWidth = YES;
    //设置最小字体  (**)
    textField.minimumFontSize = 11.0;
    //键盘颜色
    /*
     1、UIKeyboardAppearanceAlert   深灰色
     2、UIKeyboardAppearanceDark    深灰色
     3、UIKeyboardAppearanceDefault  白色  默认颜色
     4、UIKeyboardAppearanceLight   白色
     */
    textField.keyboardAppearance = UIKeyboardAppearanceLight;
    //左视图  默认不出现
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    view.backgroundColor = [UIColor redColor];
    textField.leftView = view;
    //左视图的出现状态
    /*
     1、UITextFieldViewModeAlways  一直出现
     2、UITextFieldViewModeNever  永远不出现
     3、UITextFieldViewModeWhileEditing   起初不出现,开始输入文字时出现
     4、UITextFieldViewModeUnlessEditing   不输入文字时出现,开始输入文字时消失
     */
    textField.leftViewMode = UITextFieldViewModeAlways;
    //右视图
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    view1.backgroundColor = [UIColor yellowColor];
    textField.rightView = view1;
    //右视图的出现状态
    /*
     1、UITextFieldViewModeAlways  一直出现
     2、UITextFieldViewModeNever  永远不出现
     3、UITextFieldViewModeWhileEditing   起初不出现,开始输入文字时出现
     4、UITextFieldViewModeUnlessEditing   不输入文字时出现,开始输入文字时消失
     */
//    textField.rightViewMode = UITextFieldViewModeAlways;
    //判断输入框是否正在编辑
//    textField.editing
    NSLog(@"%hhd",textField.editing);
    //获取输入框内的文字
//    textField.text
    NSLog(@"%@",textField.text);
    /*!!!!!!!!!!!!!!!代理!!!!!!!!!!!!!!!!!*/
    textField.delegate = self;
//当return键被点击时会触发这个方法
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    //失去第一响应
    [textField resignFirstResponder];
    //开始第一响应
//    [textField becomeFirstResponder];
    return YES;
}
/*
//失去第一响应
[textField resignFirstResponder];
//开始第一响应
[textField becomeFirstResponder];
 */
//开始编辑时调用
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    self.view.frame = CGRectMake(0, -216, self.view.frame.size.width, self.view.frame.size.height);
}
//结束编辑时调用
- (void)textFieldDidEndEditing:(UITextField *)textField{
    self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
//是否可清除内容
- (BOOL)textFieldShouldClear:(UITextField *)textField{
    if ([textField.text isEqualToString:@"hhh"]) {
        return NO;
    }
    return YES;
}
//是否可以开始编辑
- (BOOL)textFieldShouldBeginEditing:(UITextField *)
    textField{
    if ([textField.text isEqualToString:@"wenzi"]) {
        return NO;
    }
    return YES;
}
//是否可以结束编辑
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    if ([textField.text isEqualToString:@"oo"]) {
        return NO;
    }
    return YES;
}

/****************页面跳转(模态)******************/
    SecondViewController *second = [[SecondViewController alloc] init];
    //推送到下一页
    [self presentViewController:second animated:YES completion:^{
        //
    }];
    //返回上一页
    [self dismissViewControllerAnimated:YES completion:^{
        //
    }];

/****************AppDelegate传值******************/
    //声明AppDelegate
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    //赋值
    appDelegate.str = @"gggggggg";
    //读取appDelegate里的值
    AppDelegate *app = [[UIApplication sharedApplication] delegate];
    NSLog(@"gggggg%@",app.str);

/****************导航控制器******************/
    RootViewController *root = [[RootViewController alloc]init];
    //导航控制器需要接收一个视图控制器作为根视图控制器
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:root];
    self.window.rootViewController = nav;
    //状态栏高度为20(电量条的那一块)
    //导航栏的高度为44(电量条下面到线的上面)
    //他们的总体高度为64
    //以后创建的控件起点位置为(0,64)

/****************页面跳转******************/
   //推送到下一页
    [self.navigationController pushViewController:first animated:YES];
    //返回到上一页
    [self.navigationController popViewControllerAnimated:YES];
    //返回到首页
    [self.navigationController popToRootViewControllerAnimated:YES];
    //找到已经创建的所有的视图控制器
    NSArray *array = self.navigationController.viewControllers;
    //返回到指定的某一页
    [self.navigationController popToViewController:array[1] animated:YES];

/****************导航栏navigationBar******************/
    //所有的导航控制器共用一个导航栏
    //320*44(竖屏)  480*32(横屏)
    //找到导航栏的方法self.navigationController.navigationBar
    //设置导航栏风格:默认UIBarStyleDefault,现在其他三个黑色现在无区别
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    //设置背景颜色:颜色不纯正
//    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    //设置颜色:颜色较纯正
//    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    //设置图片
    //竖屏:UIBarMetricsDefault
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbar"] forBarMetrics:UIBarMetricsDefault];
    //横屏:UIBarMetricsLandscapePhone
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav-32.png"] forBarMetrics:UIBarMetricsLandscapePhone];
    //导航栏的隐藏属性
//    self.navigationController.navigationBarHidden = NO;
    [self.navigationController setNavigationBarHidden:NO animated:YES];


    /****************导航栏元素navigationItem******************/
    //设置标题
    self.title = @"页面一";
    self.navigationItem.title = @"hhhh";
    //设置标题头(自定义UIView)
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
    label.text = @"label";
    label.textColor = [UIColor cyanColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.backgroundColor = [UIColor redColor];
    label.font = [UIFont systemFontOfSize:24.0];
    self.navigationItem.titleView = label;
    //导航栏的按钮样式1(更改文字)
    UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"left" style:UIBarButtonItemStylePlain target:self action:@selector(leftButton)];
    //添加到导航栏的左边
    self.navigationItem.leftBarButtonItem = left;
    //导航栏的按钮样式2(系统样式)
    UIBarButtonItem *right1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(right1Click)];
    //添加到导航栏的右边
    self.navigationItem.rightBarButtonItem = right1;
    //导航栏的按钮样式3(自定义图片)
    UIBarButtonItem *right2 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"itemImage.png"] style:UIBarButtonItemStylePlain target:self action:@selector(right1Click:)];
    //添加到导航栏的右边(一个)
    self.navigationItem.rightBarButtonItem = right2;
    //右边数组里面有几个,就出现几个  (由右向左)(多个)
    //左边的话是由左向右的
    self.navigationItem.leftBarButtonItems = @[right1,right2];
    //导航栏的按钮样式4(自定义按钮)
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
    button1.frame = CGRectMake(0, 0, 32, 32);
    button1.backgroundColor = [UIColor redColor];
    [button1 setTitle:@"right" forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc]initWithCustomView:button1];
    self.navigationItem.rightBarButtonItem = rightBtn;
//带参格式
- (void)right1Click:(UIBarButtonItem *)barButton{
    NSLog(@"itemClick");
}
//不带参数格式
- (void)itemClick{
    NSLog(@"itemClick");
}

/****************UIToolBar******************/
    //下面的工具栏(320*44)
    self.navigationController.toolbarHidden = NO;
    //找到ToolBar 的方式self.navigationController.toolbar
    //更改toolBar的图片
    [self.navigationController.toolbar setBackgroundImage:[UIImage imageNamed:@"toolBar.png"] forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];
    //设置按钮样式1(系统)
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(itemClick)];
    //设置按钮样式2(文字)
    UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"button" style:UIBarButtonItemStylePlain target:self action:@selector(itemClick:)];
    //设置按钮样式3(图片)
    UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"itemImage.png"] style:UIBarButtonItemStylePlain target:self action:@selector(itemClick)];
    //创建空格(可均分相应的空位)
    UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(itemClick)];
    //添加到数组里
    NSArray *array = @[space,item1,space,item2,space,item3,space];
    //设置toolBar的按钮
    self.toolbarItems = array;
//带参格式
- (void) itemClick:(UIBarButtonItem *)barButton{
    NSLog(@"itemClick");
}
//不带参数格式
- (void)itemClick{
    NSLog(@"itemClick");
}

/****************UIAppearance******************/
    //创建字典
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:30.0],NSForegroundColorAttributeName:[UIColor redColor]};
    //整体更改navigationBar上面title的文字大小及颜色
    [[UINavigationBar appearance] setTitleTextAttributes:dic];



基于CST的PCB通孔三维建模实例 本文简明扼要地描述了如何利用CST的参数化脚本快速生成PCB的通孔三维模型,非常适合于进行快速精准的PCB参数分析。 阅读详情

相关推荐

部署资源管理系统chemx

资源管理系统的部署教程

weixin_40784215的博客 822

IOS键盘上的“Next”按钮事件,定位到下一个文本框

IOS键盘上的“Next”按钮事件,定位到下一个文本框 1.视图控制器实现UITextFieldDelegate协议 2.设置文本框属性(返回按钮在键盘上的返回类型,此处是Next) _NameTextField.returnKeyType = UIReturnKeyNext;   _IDCardTextField.returnKeyType = UIReturnKeyNext;    

shiningchen322的博客 3553

别再傻傻分不清!5分钟搞懂倾斜摄影里‘地面分辨率’和‘模型精度’到底啥关系

本文深入解析倾斜摄影中‘地面分辨率’与‘模型精度’的关系,帮助读者快速理解两者的本质区别与内在关联。通过实战案例和公式计算,详细说明如何从航飞设计到精度验证全流程控制,避免常见认知误区,并针对不同应用场景提供精度需求建议。

weixin_33700350的博客 477

改变系统键盘的return键,UIReturnKeyTeype

UIReturnKeyType The text string displayed in the “return” key of a keyboard. typedef enum {    UIReturnKeyDefault,    UIReturnKeyGo,    UIReturnKeyGoogle,    UIReturnKeyJoin,    UIReturnKeyNe

lct710992308的博客 752

华为云Stack交付实战:从工勘到上线的全流程拆解

本文详细拆解华为云Stack交付全流程,从项目启动、工勘、LLD设计到硬件部署和软件安装,提供实战技巧与避坑指南。重点解析华为云Stack交付流程中的关键环节,如标准化工具使用、规范化文档管理和流程化协作,帮助团队高效完成从工勘到上线的复杂项目交付。

weixin_29243063的博客 156

vscode远程开发-调试模式下attach远程进程提示管理员权限失败的问题

vscode 远程开发 附加进程

comhaqs的专栏 2878

iOS 键盘属性及退出几种方法(UITexfield 和 UITextView)

UITe'x't #pragma mark - UITextView Delegate Methods -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if ([text isEqualToStri

天微微亮 1586

用Arduino Mega2560和TB6612驱动MG513电机,我踩过的坑和最佳实践

本文详细介绍了使用Arduino Mega2560和TB6612驱动模块控制MG513直流电机的实战经验,包括硬件连接、PWM配置、编码器信号处理等关键技巧。通过优化电源系统、信号线布局和软件控制算法,有效解决了电机抖动、转速不稳等常见问题,为机器人底盘和自动化项目提供了可靠解决方案。

weixin_42520573的博客 201

iOS 键盘回车键(换行、回车符)修改

UITextField 和 UITextView 如图修改键盘 开源地址,可点击查看 UIReturnKeyDefault UIReturnKeyGo UIReturnKeyGoogle UIReturnKeyJoin UIReturnKeyNext UIReturnKeyRoute UIReturnKeySearch UIReturnKeySend 加粗样式 UIReturnKeyDone UIReturnKeyEmergencyCall UIReturnKeyContinue U

怪兽的猫的博客 3292

华为OD机试真题 新系统 2026-04-19 Java&Go 实现【分辨率排序】

华为OD机试真题 新系统 2026-04-19 Python&JS 实现【分辨率排序】

MISAYAONE的博客 303

基于Python的MOOC课程评价爬取与分析系统设计与实现

本文详细介绍了如何使用Python最新技术栈构建一个高效的MOOC课程评价爬取与分析系统。系统采用Scrapy框架结合Selenium实现动态页面抓取,利用PyMySQL进行数据存储,并通过Pandas和Matplotlib实现数据可视化分析。文章从爬虫原理、技术选型、系统设计到代码实现进行全面讲解,为教育工作者改进教学质量提供数据支持。关键词:Python爬虫、MOOC评价分析、Scrapy框架、数据可视化、教学改进。

2201_76125261的博客 1103

开源 iOS 项目分类索引大全

GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助 系统基础库 Category/Util  sstoolkit 一套Category类型的库,附带很多自定义控件 功能不错~  BlocksKit 将Block风格带入UIKit和Founc

stevenlfg的专栏 1625

Open3D——点云构建Delaunay三角网【2026最新版】

点云构建Delaunay三角网

点云侠的博客 8367

iOS OC基础知识笔记

iOS OC基础知识笔记 一个NSObject对象占用多少内存? 系统分配了16个字节给NSObject对象(通过malloc_size函数获得) 但NSObject对象内部只使用了8个字节的空间(64bit环境下,可以通过class_getInstanceSize函数获得) #import <objc/runtime.h> #import <malloc/malloc.h&...

WJ的博客 1484

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

iOS开发学习笔记:基础篇

iOS开发需要一台Mac电脑、Xcode以及iOS SDK。因为苹果设备都具有自己封闭的环境,所以iOS程序的开发必须在Mac设备上完成(当然,黑苹果应该也是可以的,但就需要花很多的精力去折腾基础环境),Xcode是一个集成开发环境,包括了编辑器、调试、模拟器等等一系列方便开发和部署的工具,iOS SDK则是开发应用所必需,不同的SDK分别对应不同的iOS版本或设备,通常我们需要下载...

aifeier1982的博客 218

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

iOS学习笔记1——OC基础

目录OC语言基础OC与Cprintf与NSLog的区别函数和方法的区别方法的注意点初学常见报错情况#pragma mark的使用OC面向对象概念NString基本使用修改项目模板匿名对象descriptiongetter和setter方法super关键字 OC语言基础 OC与C OC完全兼容C, 所以可以在OC程序中编写C语言代码,并且可以将C语言的源文件和OC的源文件组合在一起生成可执行文件。 printf与NSLog的区别 NSLog会自动换行 NSLog在输出内容时会附加一些系统信息(含有对象的内存

weixin_44250824的博客 1263

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

iOS开发笔记 3、iOS基础

系统规格 iPhone的规格 Each is a 4.7- or 4.8-ounce computing device. Each contains a 620 MHz ARM CPU that has been underclocked to improve battery performance and reduce heat. The iPhone and iPhone 3G ...

weixin_30696427的博客 77

ios基础学习笔记

资源位置的问题 资源分文件(比如图片)和文件夹 图片资源 拖拽一张普通图片到xcode的工程的Assets.xcassets中。 拖拽3张相同内容的1x 、2x、 3x普通图片到xcode的工程的Assets.xcassets中。 拖拽一张普通图片到xcode的工程的代码所属的文件夹里面。 在代码里面分别读取Assets.xcassets里面和xcode的工程的代码所属的文件夹里面的图片。代...

u010919133的专栏 515

IOS开发学习笔记Day1-OC基础一

IOS开发学习笔记Day1-OC基础一简单类的声明与实现类的方法有返回值,参数,多个参数,标签的方法类方法OC 中的字符串代码标记,分割修改代码模版开发文档安装 简单类的声明与实现 #import <Foundation/Foundation.h> // 类名后面的 :NSObject 是为了让我们的Iphone类具备创建对象的能力 @interface Iphone : NSObje...

lijianbiao0的博客 585

iOS UI学习笔记(一)UIView基础

在培训机构学习的iOS编程,写写博客做一回顾,希望大家多多指点。 主要内容: UI期的基础类  UIView 1.视图的位置和大小的确定,需要在视图初始化的时候(initWithFrame)需要传递一个参数,此参数为结构体(CGRect)其实就是一个矩形,该矩形分为两部分,一个用来确定位置(origin.x&origin.y)一个用来确定大小(size.width&size.height).

q408896553的博客 784

Java Swing程序打包exe实战:exe4j封装原理与工程落地

Java桌面应用以.jar为标准分发形式,但面向Windows终端用户时,需转化为双击即用的.exe文件——这并非简单格式转换,而是运行时环境封装与交付体验重构。核心在于解决JRE依赖、UI线程安全、原生窗口集成及企业级部署兼容性等关键问题。exe4j作为成熟方案,通过JNI桥接实现JVM动态加载、Swing EDT保障、图标/UAC/版本信息嵌入等能力,显著优于Launch4j等替代工具。尤其在Swing/AWT类GUI项目中,其对Java 5–21全版本兼容、任务管理器进程名控制、无黑窗启动等特性,构成

weixin_34387468的博客 283

iOS学习笔记(七)——UI基础UIButton

前面写了UIWindow、UIViewController,那些都是一些框架,框架需要填充上具体的view才能组成我们的应用,移动应用开发中UI占了很大一部分,最基础的UI实现是使用系统提供的各种控件,其他的就是自定义实现了,作者目前是入门状态,只能写写基础控件了。      iOS中提供了UIButton、UILable、UITextField、UIImageView等基础UI控件,继承于UIV

1万+

笔记:ios开发基础

1 打包成framework,lipo -create -output  3.framework   2.framwrok 1.framwork,即将1.2合并打包成1; 用lips -info 1.framework查看是否成功; 2 iOS app开发库官方建议只支持.a  framework 格式;so只有系统自带支持。

技行天下的博客 415

iOS基础网络编程学习笔记

iOS进行网络交互的过程是在Web Service应用层进行的,而Web Service采用的Http和Https协议 1.Http概述: Http(Hypertext Transfer Protocol)是超文本传输协议,基于TCP/IP协议之上的应用层的协议。Http协议支持C/S网络结构,是无连接协议,即是每次都有请求建立连接,当服务器处理完客户端请求,应答完成后就会断开链接,不会一直占...

wangyongyao1989的博客 604
github_34702824
博客等级 码龄11年 0粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值