• 导航条按钮的设置UIBarButtonItem


    1、目的

    2、代码

    // 设置导航栏的按钮
    UIButton *leftNavBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    UIImage *leftNavImage = CHImageWithName(@"navBar_schoolTask");
    leftNavImage = [leftNavImage imageWithTintColor:[ChanTool appTextColor]];
    [leftNavBtn setBackgroundImage:leftNavImage forState:UIControlStateNormal];
    [leftNavBtn addTarget:self action:@selector(leftNavClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftNavButton = [[UIBarButtonItem alloc] initWithCustomView:leftNavBtn];;
    self.navigationItem.leftBarButtonItem = leftNavButton;
    
    // 设置导航栏的按钮
    UIButton *rightNavBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    UIImage *rightNavImage = CHImageWithName(@"navBar_takePhoto");
    rightNavImage = [rightNavImage imageWithTintColor:[ChanTool appTextColor]];
    [rightNavBtn setBackgroundImage:rightNavImage forState:UIControlStateNormal];
    [rightNavBtn addTarget:self action:@selector(rightNavClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightNavButton = [[UIBarButtonItem alloc] initWithCustomView:rightNavBtn];;
    self.navigationItem.rightBarButtonItem = rightNavButton;
    

    3、事件

    - (void)leftNavClick:(UIButton *)button {
    
    
    }
    
    - (void)rightNavClick:(UIButton *)button {
    
    }
    
  • 相关阅读:
    hduoj 1865 1string 【大数】【菲波那切数列】
    poj 1664 放苹果【M的N划分】
    新年第一篇
    3、XCode: 如何添加自定义代码片段
    2、文件夹
    1、获取当前屏幕显示的页面
    运算符
    表单数据接收
    PHP进入MySQL数据库
    my SQL认识和进入
  • 原文地址:https://www.cnblogs.com/CH520/p/11485258.html
Copyright © 2020-2023  润新知