添加个导航栏:

 
 
    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. 【LaTeX排版】LaTeX纸排版&lt;两&gt;

    1.文件夹的生成     直接使用命令\tableofcontents就可以. 其默认格式例如以下: 我们会发现.这种格式不一定是我们所期望的. 比方说,我们也希望章标题与页码之间也有点连线,而且也希 ...

  2. JavaScript编写了一个计时器

    初学JavaScript,用JavaScript编写了一个计时器. 设计思想: 1.借助于Date()对象,来不断获取时间点: 2.然后用两次时间点的毫秒数相减,算出时间差: 3.累加时间差,这样就能 ...

  3. 组态ORACLE 11G ADG

    一旦载10g的,没有票据.昨天使用duplicate方法一安装11g ADG,过程艰辛,记录: 一.环境配置 主图书馆 IP地址:192.168.233.128/24 操作系统版本号:rhel5.8 ...

  4. 华为G520联通版刷机包 基于MIUI CM11新 平稳 稳定

    ROM介绍 刷先配置双卡:"设定-安卓原生设置-双卡套-配置订阅",否则,无信号 使开发人员选项方法:"设定-安卓原生设置-关于手机-发布"连续点击版本 启用A ...

  5. javascript 中的location.pathname

    1 location.pathname; 这在之前我没怎么注意过,所以研究研究.location.pathname:返回URL的域名(域名IP)后的部分.例如 http://www.joymood.c ...

  6. 经典算法题每日演练——第十四题 Prim算法

    原文:经典算法题每日演练--第十四题 Prim算法 图论在数据结构中是非常有趣而复杂的,作为web码农的我,在实际开发中一直没有找到它的使用场景,不像树那样的频繁使用,不过还是准备 仔细的把图论全部过 ...

  7. Ubuntu中编译链接Opencv应用的简便方式

    安装完毕Opencv后,使用下面命令查 看编译/连接參数 pkg-config --cflags --libs opencv 可看到例如以下信息 -I/usr/include/opencv  /usr ...

  8. SQL Server AlwaysON 同步模式的疑似陷阱

    原文:SQL Server AlwaysON 同步模式的疑似陷阱 SQL Server 2012 推出的最重要的功能之一Alwayson,是一个集之前Cluster和Mirror于一体的新功能,即解决 ...

  9. Jquery zTree实例

    zTree[简单介绍] zTree 是利用 JQuery 的核心代码,实现一套能完毕大部分经常使用功能的 Tree 插件 兼容 IE.FireFox.Chrome 等浏览器 在一个页面内可同一时候生成 ...

  10. css3简单几步画一个乾坤图

    原文:[原创]css3简单几步画一个乾坤图 效果如上,鼠标移上去会有动画. 代码如下非常简单: <html> <head> <style> .outer{heigh ...