添加个导航栏:

 
 
    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. android 拍照注意问题

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, reqCode) ...

  2. windows server 2008见安装IIS方法(解决)

    windows server 2008见安装IIS方法(解决) 刚开始有点蒙,后来才知道原来如此.! . 右键点击[我的电脑]--[管理]--[字符]--[加入角色]--仅落后win7像.啊! 版权声 ...

  3. asp.net学习之GridView七种字段

    原文:asp.net学习之GridView七种字段 asp.net中GridView绑定到数据源时,可以自动显示数据源的各个字段.只要设定其AutoGenerateColumns为TRUE即可.但这, ...

  4. IOS View传统的价值观之间

    1.采用NSUserDefaults通过值,这样的方法不限于传送少量数据的: 比方你要传一个float的值.在须要传的时候用 [[NSUserDefaults standardUserDefaults ...

  5. [Mac] Mac book pro互换SSD硬盘、生产启动U菜、TimeMachine恢复 小记

    Mac book pro 硬盘故障.互换SSD硬盘.启动U磁盘生产 小记 2012新年买Mbp了.尽管各种功能都能用,但常常频繁的出现鼠标风火轮,已经下好的电影在本地播放时都会隔个几分钟卡一下. 拿到 ...

  6. 为什么数据线easy糟糕

    一个好的设计可以帮助解决问题似乎无关紧要豪. 两天前M3数据线被破坏.在弯附近的电话插口可以充电.一松就充不了电了. 今天突然想到每次充电的时候用手机发信息.玩游戏都特别不方便,才想到为什么数据线ea ...

  7. Redhat Linux挂载NTFS格式的移动硬盘

    Redhat Linux挂载NTFS格式的移动硬盘 1. 选择下载ntfs-3g的源码包或rpm包 http://www.tuxera.com/community/open-source-ntfs-3 ...

  8. ResultSet 转为 List或者JavaBean

    一.将ResultSet结果集转换为List,其中每条记录信息保存为Map放到List中,方法如下: public static List<Map<String, Object>&g ...

  9. AngularJS之使用服务封装

    AngularJS之使用服务封装可复用代码   创建服务组件 在AngularJS中创建一个服务组件很简单,只需要定义一个具有$get方法的构造函数, 然后使用模块的provider方法进行登记: / ...

  10. easyui datagrid load 封装 参数问题 js 作用域

    var temp = { LoginAccount: $('#LoginAccount').val(), ShopName: $('#ShopName').val() }; function doSe ...