添加个导航栏:

 
 
    Xib1 *xib1 = [[Xib1 alloc] initWithNibName:@"Xib1" bundle:nil];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:xib1];
    
    
    self.window.rootViewController = navController;
 
xib1:
- (IBAction)nextPage:(id)sender {
    self.title = @"一";
    Xib2 *xib2= [[Xib2 alloc] initWithNibName:@"Xib2" bundle:nil];
    
    xib2.modalPresentationStyle = UIModalPresentationCustom;
    [self.navigationController pushViewController:xib2 animated:YES];
}
 
xib2:
- (IBAction)BackfirstPage:(id)sender {
    Xib3 *xib3 = [[Xib3 alloc] initWithNibName:@"Xib3" bundle:nil];
    UIViewController *popVC = self.navigationController.viewControllers[0];
    [self.navigationController pushViewController:xib3 animated:YES];
    popVC.title = @"First Page";
}
 
 
 
xib3:
- (IBAction)BackRoot:(id)sender {
    UIViewController *popVC = self.navigationController.viewControllers[0];
    [self.navigationController popToViewController:popVC animated:YES];
    popVC.title = @"First Page";
    
}
- (IBAction)Back:(id)sender {
    UIViewController *popVC = self.navigationController.viewControllers[1];
    [self.navigationController popViewControllerAnimated:YES];
     popVC.title = @"Second Page";
}
 
 
适配导航栏:
 
第一步:
Supporting Files -> Shipaei67-Info.plist -> View controller-based status bar (拉动第一个栏找这个选项) Value : NO
第二步:
项目->Deployment Info -> Status Bar Style : Black Translucent
做完前两步,导航条上面的字体就有白色变成黑色了
电池栏距离:0-20
导航栏距离:0-44
 
定义IOS 版本:
 
#define ISiOS7 ([UIDevice currentDevice].systemVersion.floatValue>=7.0)
 
 
关于导航栏的方法:
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    //判断是否是iOS7
    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];
    
}
-(void)onLeftBarButtonClicked:(id)sender{
    NSLog(@"自定义导航条按键被点击");
}
-(void)onBarButtonItemClicked:(id)sender{
    NSLog(@"导航条按键被点击");
}

 
 
通知栏:
 
main:
 
@implementation QFAppDelegate{
    Dog *dog;
    Person *person;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    dog=[[Dog alloc]init];
    person=[[Person alloc]init];
    //让人接收通知,把人注册到通知中心中
    [[NSNotificationCenter defaultCenter]addObserver:person selector:@selector(beatThief:) name:@"狗叫:bark!!!" object:Nil];
    
    UIButton *button=[UIButton buttonWithType:UIButtonTypeContactAdd];
    button.frame=CGRectMake(100, 100, 50, 50);
    [button addTarget:self action:@selector(makeDogBark:) forControlEvents:UIControlEventTouchUpInside];
    [self.window addSubview:button];

 
-(void)makeDogBark:(id)sender{
    [dog findThief];
}
 
 
Dog.h
 
#import "Dog.h"

@implementation Dog
-(void)findThief{
    NSString *model=@"测试的数据模型";
    //利用通知中心发通知
    [[NSNotificationCenter defaultCenter]postNotificationName:@"狗叫:bark!!!" object:model];
}
@end

 
Person.m
 
@implementation Person
-(void)beatThief:(id)sender{
//    NSLog(@"%@",sender);
    NSLog(@"抄家伙,打贼!");
    NSNotification *notice=sender;
    NSString *testModel=notice.object;
    NSLog(@"测试数据的传递:%@",testModel);
}
@end
 
 
系统通知:
 
@implementation QFRegistViewController{
    CGRect buttonOldRect;
    UITapGestureRecognizer *tapGR;//添加单击手势
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (void)viewDidLoad{
    [super viewDidLoad];
    
    /*
     数据传递
     1、首先,数据已经存在了!
     2、谁需要,就声明几个指针。
     3、在实例化2那个对象的时候,将声明的几个指针指向正确是数据。
     4、至此,数据传递完成,可以使用了。
     
     */
    
    //将自己加入通知中心
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onKeyBoradShow:) name:UIKeyboardWillShowNotification object:Nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onKeyBoradHide:) name:UIKeyboardWillHideNotification object:Nil];
    buttonOldRect=self.goDetailButton.frame;
    
    //实例化单击手势
    tapGR=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onTap:)];
    
}
//单击手势的响应函数
-(void)onTap:(id)sender{
    //将输入框取消第一响应者,键盘就睡自动收回
    [self.nameTextField resignFirstResponder];
    [self.passwordTextField resignFirstResponder];
}
//收到键盘将要弹起的通知后,调用的函数
-(void)onKeyBoradShow:(id)sender{
    [self.view addGestureRecognizer:tapGR];
    NSLog(@"%@",sender);
    //将sender转化成notice类型
    NSNotification *notice=sender;
    //获取通知里面的userinfo
    NSDictionary *userInfo = notice.userInfo;
    //在userinfo中获取键盘最后的状态rect
    id keyBoardRectNotice = userInfo[UIKeyboardFrameEndUserInfoKey];
    //将上面获得的rect对象,提取出cgrect
    CGRect keyBoardRect;
    [keyBoardRectNotice getValue:&keyBoardRect];
    //用获得的cgrect来设置button的frame;
    CGRect buttonNewFrame=buttonOldRect;
    //原来的按键frame减去键盘的高度,生成新的frame
    buttonNewFrame.origin.y-=keyBoardRect.size.height;
    [UIView animateWithDuration:0.2 animations:^{
        self.goDetailButton.frame=buttonNewFrame;
    }];
    
    
}
//收到键盘将要收回的通知后,调用的函数
-(void)onKeyBoradHide:(id)sender{
    [self.view removeGestureRecognizer:tapGR];
    [UIView animateWithDuration:0.3 animations:^{
        self.goDetailButton.frame=buttonOldRect;
    }];
}
//按键函数
- (IBAction)goDetail:(id)sender {
    NSString *name=self.nameTextField.text;
    NSString *password=self.passwordTextField.text;
    
    //生成数据模型
    QFUserModel *model=[[QFUserModel alloc]init];
    model.name=name;
    model.pass=password;
    
    QFDetailViewController *detailVC=[[QFDetailViewController alloc]initWithNibName:@"QFDetailViewController" bundle:Nil];
    //将数据模型传入
    detailVC.model=model;
    
    [self presentViewController:detailVC animated:YES completion:^{
        
    }];
    
}

//销毁函数,用于移除通知
-(void)dealloc{
    //在销毁的时候将自己在通知中心中移除
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
@end

 
 
 
 
 
 
 
 

IOS UI 第五篇:基本UI的更多相关文章

  1. IOS设计模式第五篇之装饰设计模式的代理设计模式

    版权声明:原创作品,谢绝转载!否则将追究法律责任. 代理: 另一个装饰设计模式,代理,是一个代表或者协调另一个对象的行为机制.例如当你用一个tableView,你必须实现他里面的一个tableView ...

  2. IOS UI 第八篇:基本UI

    实现图片的滚动,并且自动停止在每张图片上     - (void)viewDidLoad{    [super viewDidLoad]; UIScrollView *scrollView = [[U ...

  3. iOS进阶指南试读之UI篇

    iOS进阶指南试读之UI篇 UI篇 UI是一个iOS开发工程师的基本功.怎么说?UI本质上就是你调用苹果提供给你的API来完成设计师的设计.所以,想提升UI的功力也很简单,没事就看看UIKit里的各个 ...

  4. 四核驱动的三维导航—淘宝新UI(设计篇)

    前面有一篇博客说到了淘宝UWP的"四核驱动的三维导航—淘宝新UI(需求分析篇)",花了两周的时间实现了这个框架,然后又陆陆续续用了三周的时间完善它. 多窗口导航,与传统的导航方式的 ...

  5. 游戏模块分析总结(2)之UI、操作篇

    转自:http://www.gameres.com/309812.html 游戏模块分析总结(2)之UI.操作篇 发布者: wuye | 发布时间: 2014-12-12 15:03| 评论数: 0 ...

  6. 环信 之 iOS 客户端集成四:集成UI

    在Podfile文件里加入 pod 'EaseUI', :git => 'https://github.com/easemob/easeui-ios-cocoapods.git' 然后在终端中的 ...

  7. WPF 精修篇 非UI进程后台更新UI进程

    原文:WPF 精修篇 非UI进程后台更新UI进程 <Grid> <Grid.RowDefinitions> <RowDefinition Height="11* ...

  8. 利用手上的UI资源(附免费UI工具包)

    http://www.uisdc.com/how-to-use-ui-kits# 大家都知道,UI工具包里有很多好看的资源:比如按钮.滑块.面包屑.播放器.表单,甚至是一个"赞!" ...

  9. EnjoyingSoft之Mule ESB开发教程系列第五篇:控制消息的流向-数据路由

    目录 1. 使用场景 2. 基于消息头的路由 2.1 使用JSON提交订单的消息 2.2 使用XML提交订单的消息 2.3 使用Choice组件判断订单格式 3. 基于消息内容的路由 4. 其他控制流 ...

随机推荐

  1. Navicat工具Oracle数据库复制 or 备用、恢复功能(评论都在谈论需要教)

    GXPT它是一个分布式系统,该系统包括一个临时许可系统.基本系统.教学评价体系.考试系统,每个系统都有自己的oracle数据库.统,而评教系统的正常须要借助于权限系统和基础系统,详细的业务这里就不多解 ...

  2. 平均得分 【杭州电-HDOJ-2023】 附加题+详细说明

    /* 平均得分 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  3. 最长公共子序列问题 (LCS)

    给定两个字符串S和T.求出这两个字符串最长的公共子序列的长度. 输入: n=4 m=4 s="abcd" t="becd" 输出: 3("bcd&qu ...

  4. AMR音频文件格式分析

    AMR音频文件格式分析 1 概要 如今非常多智能手机都支持多媒体功能,特别是音频和视频播放功能,而AMR文件格式是手机端普遍支持的音频文件格式.AMR,全称是:Adaptive Multi-Rate, ...

  5. Extjs4.1MVC详细解释

    :http://xiebaochun.github.io/ app.js [javascript] view plaincopyprint? Ext.onReady(function(){ Ext.Q ...

  6. 从头开始学JavaScript (六)——语句

    原文:从头开始学JavaScript (六)--语句 一.条件分支语句:if 基本格式: if (<表达式1>){    <语句组1>}else if (<表达式2> ...

  7. CSS3 制作向左、向右及关闭图标的效果 (另一种思路)

    最终效果 制作步骤 1.边框 CSS及Html代码 显示效果 2.向左的标志 CSS及Html代码,增加的代码在黄色范围内 显示效果 方向不对了,马上修改一下方向,逆时针旋转45度调整一下 CSS及H ...

  8. linux虚拟文件系统2

    转自:http://rstevens.iteye.com/blog/849413 一.概述 Linux 文件系统是相当复杂的,本文只分析虚拟文件系统的实现,对具体的文件系统不涉及. 即使是虚拟文件系统 ...

  9. Docker 管理工具 Shipyard

    Docker 管理工具 Shipyard Shipyard 是一个基于 Web 的 Docker 管理工具,支持多 host,可以把多个 Docker host 上的 containers 统一管理: ...

  10. [C#]设置或取消开机启动(注册表形式)

    原文:[C#]设置或取消开机启动(注册表形式) 使用代码: 代码效果: