添加个导航栏:

 
 
    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. ViewPager用法

    第一图:          页面中填充内容是随机关键词飞入和飞出动画效果,随后会更新,如今请先无视吧 ---2015-02-27--- 两年后最终更新了,网上都能搜到的,哎 无奈太懒http://bl ...

  2. 3 sum

    3-sum 标题叙述性说明: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = ...

  3. hibernate 管理 Session(单独使用session,不spring)

    Hibernate 本身提供了三个管理 Session 对象的方法 Session 对象的生命周期与本地线程绑定 Session 对象的生命周期与 JTA 事务绑定 Hibernate 托付程序管理 ...

  4. 基于Android的ELF PLT/GOT符号和重定向过程ELF Hook实现(by 低端农业代码 2014.10.27)

    介绍 技术原因写这篇文章,有两种: 一个是在大多数在线叙述性说明发现PLT/GOT第二十符号重定向过程定向x86的,例<Redirecting functions in shared ELF l ...

  5. 深入探讨 Java 类加载器[转]

    原文地址:http://www.ibm.com/developerworks/cn/java/j-lo-classloader/index.html 类加载器(class loader)是 Java™ ...

  6. HDU 2616 Kill the monster (暴力搜索 || 终极全阵列暴力)

    主题链接:HDU 2616 Kill the monster 意甲冠军:有N技能比赛HP有M怪物,技能(A,M),能伤害为A.当怪兽HP<=M时伤害为2*A. 求打死怪兽(HP<=0)用的 ...

  7. 细说 ASP.NET Cache 及其高级用法【转】

    阅读目录 开始 Cache的基本用途 Cache的定义 Cache常见用法 Cache类的特点 缓存项的过期时间 缓存项的依赖关系 - 依赖其它缓存项 缓存项的依赖关系 - 文件依赖 缓存项的移除优先 ...

  8. FindBugs:Compiler output path for module can not be null. check your module/project settings问题原因

    这可能是很多人在使用Android studio 该插件会发现此错误信息:Compiler output path for module can not be null. check your mod ...

  9. 在遍历中使用 iterator/reverse_iterator 进行 Erase 的使用方法

    在遍历中使用 iterator/reverse_iterator 进行 Erase 的使用方法 罗朝辉 (http://blog.csdn.net/kesalin/) 本文遵循"署名-非商业 ...

  10. Mac下Android配置及unity3d的导出Android

    昨晚实在弄的太晚了,费尽脑汁才弄出来. ok,关于mac下的eclipse的安卓配置,我仅仅贴一个网址,就ok了 http://developer.android.com/sdk/index.html ...