UINavigationController使用

UINavigationController实例化与自定义
本文详细介绍了如何使用UINavigationController实例化,并展示了在不同iOS版本下如何自定义导航栏的外观,包括颜色、标题、按钮等。
    FirstViewController *firstVC=[[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:Nil];
    //实例化导航控制器
    UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:firstVC];
    
    //将包装好的导航控制器,作为rootviewcontroller
    self.window.rootViewController=navController;


以上是UINavigationController实例化


----------------------------------------------------------------------------------------------------------------------------------------------------------------------

使用UINavigationController推出下一个页面:

[self.navigationController pushViewController:secondVC animated:YES];

UINavigationController各种属性设置

    if (ISiOS7) {
        //在IOS7里,这个是设置导航条文字的颜色
        self.navigationController.navigationBar.tintColor=[UIColor redColor];
        //在IOS7里,这个是设置导航条背景的颜色
        self.navigationController.navigationBar.barTintColor=[UIColor blueColor];

    }else{
        //不是ios7,只能设置导航条的颜色
        self.navigationController.navigationBar.tintColor=[UIColor orangeColor];
    }
    //自定义标题
    UILabel *titleLable=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    //ios6里,label默认背景是白色,但是ios7默认透明
    if (!ISiOS7) {
        titleLable.backgroundColor=[UIColor clearColor];
    }
    titleLable.text=self.title;
    titleLable.font=[UIFont boldSystemFontOfSize:20];
    titleLable.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=titleLable;
    
    
    //自定义导航条按键(利用系统自带的样式)
    UIBarButtonItem *barButtonItem1=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(onBarButtonItemClicked:)];
    UIBarButtonItem *barButtonItem2=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(onBarButtonItemClicked:)];
    
//    self.navigationItem.rightBarButtonItem=barButtonItem;//单独一个按键
    self.navigationItem.rightBarButtonItems=@[barButtonItem1,barButtonItem2];
    
    
    //自定义导航条按键,完全自定义
    UIButton *leftBarButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [leftBarButton setTitle:@"左侧按键" forState:UIControlStateNormal];
    [leftBarButton setTitle:@"左侧点击" forState:UIControlStateHighlighted];
    [leftBarButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [leftBarButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
    leftBarButton.frame=CGRectMake(0, 0, 100, 44);
    [leftBarButton addTarget:self action:@selector(onLeftBarButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    //将上面自定义的按键,包装成一个导航条按键
    UIBarButtonItem *leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBarButton];
    self.navigationItem.leftBarButtonItem=leftBarButtonItem;
    
    
    
    //设置导航条背景
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbg"] forBarMetrics:UIBarMetricsDefault];
    



转载于:https://www.cnblogs.com/zjszyms/p/4119454.html

基于距离和密度的高斯核聚类算法研究(Matlab代码实现)内容概要:本文围绕基于距离和密度的高斯核聚类算法展开研究,提出了一种结合数据点间距离与局部密度特征的聚类方法,并通过Matlab代码实现该算法。该算法利用高斯核函数衡量样本间的相似性,引入密度信息以识别簇中心,有效提升了对复杂分布数据的聚类性能,尤其适用于非凸形状或噪声干扰下的数据集。文中详细阐述了算法原理、关键参数设置及其实现流程,并通过实验验证了其相较于传统聚类方法在准确性与鲁棒性方面的优势。; 适合人群:具备一定机器学习基础和Matlab编程能力的高校学生、科研人员及从事数据分析、模式识别等相关工作的技术人员。; 使用场景及目标:①用于处理具有复杂结构或噪声较多的实际数据聚类问题,如图像分割、异常检测、客户分群等;②帮助理解密度-based与核方法相结合的聚类思想,掌握高斯核在聚类中的应用方式;③为改进现有聚类算法或开发新型聚类模型提供技术参考与实现基础。; 阅读建议:建议读者结合Matlab代码逐段理解算法实现细节,重点关注距离矩阵构建、密度计算与高斯核函数的应用部分,可通过调整参数并观察聚类结果变化加深对算法行为的理解,同时推荐在不同数据集上进行测试以评估算法泛化能力。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值