ios 中UIViewController的分类
#import <UIKit/UIKit.h> #define TOPVIEWTAG 0x10000 // 导航栏的图片 @interface UIViewController (Chnbs) -(void)setupTopNavigationView;
-(void)resizeNavigationView; -(CGRect)CGRectMake; -(void)showMessage:(NSString*)message; @en
======================
@implementation UIViewController (Chnbs) -(void)setupTopNavigationView{
self.navigationController.navigationBarHidden = YES;
UIView *tpNavView = [[UIView alloc] initWithFrame:CGRectMake(, , self.view.bounds.size.width, )];
tpNavView.tag = TOPVIEWTAG;
[self.view addSubview:tpNavView];
[tpNavView release]; UIImageView *navImageView = [UIImageView ImageViewImageName:@"top_navigation_image.png" frame:tpNavView.bounds];
navImageView.tag = ;
[tpNavView addSubview:navImageView]; UILabel *label = [UILabel LabWithFrame:tpNavView.bounds text:self.title textColor:[UIColor whiteColor] textAlign:NSTextAlignmentCenter font:[UIFont boldSystemFontOfSize:]];
[tpNavView addSubview:label];
label.tag=;
UIButton *back = [UIButton ButtonWithImageName:@"btn_back_image.png" hImageName:@"btn_back_image.png" frame:CGRectMake(, , , )
title:nil titleColor:nil font:nil target:self action:@selector(backButtonAction:)];
back.tag = 0x404;
[tpNavView addSubview:back]; //FIX 添加导航的屏幕自动适配
tpNavView.autoresizingMask=UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleWidth;
navImageView.autoresizingMask=UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleWidth;
label.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
} -(void)resizeNavigationView{
UIView *topView = ASDynamicCast(UIView, [self.view viewWithTag:TOPVIEWTAG]);
topView.frame = CGRectMake(, , self.view.bounds.size.width, ); UIImageView *image = ASDynamicCast(UIImageView, [topView viewWithTag:]);
image.frame = topView.bounds;
UILabel *tLab = ASDynamicCast(UILabel, [topView viewWithTag:]);
tLab.frame = topView.bounds; UIButton *back = ASDynamicCast(UIButton, [topView viewWithTag:0x404]);
back.frame = CGRectMake(, , , );
} -(void)backButtonAction:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
} -(CGRect)CGRectMake{
CGRect topViewRec,bottonViewRec;
CGRectDivide(self.view.bounds, &topViewRec, &bottonViewRec, , CGRectMinYEdge);
return bottonViewRec;
} -(void)showMessage:(NSString*)message{
if ([message length] > ) {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:nil message:message delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[av show];
[av release];
} } @end
ios 中UIViewController的分类的更多相关文章
- 转iOS中delegate、protocol的关系
iOS中delegate.protocol的关系 分类: iOS Development2014-02-12 10:47 277人阅读 评论(0) 收藏 举报 delegateiosprocotolc ...
- IOS中KVO模式的解析与应用
IOS中KVO模式的解析与应用 最近老翁在项目中多处用到了KVO,深感这种模式的好处.现总结如下: 一.概述 KVO,即:Key-Value Observing,它提供一种机制,当指定的对象的属性被修 ...
- iOS 中的 HotFix 方案总结详解
相信HotFix大家应该都很熟悉了,今天主要对于最近调研的一些方案做一些总结.iOS中的HotFix方案大致可以分为四种: WaxPatch(Alibaba) Dynamic Framework(Ap ...
- 谈谈iOS中的锁
1 前言 近日工作不是太忙,刚好有时间了解一些其他东西,本来打算今天上午去体检,但是看看天气还是明天再去吧,也有很大一个原因:就是周六没有预约上!闲话少说,这里简单对锁来个简单介绍分享. 2 目录 第 ...
- iOS开发——高级篇——iOS中常见的设计模式(MVC/单例/委托/观察者)
关于设计模式这个问题,在网上也找过一些资料,下面是我自己总结的,分享给大家 如果你刚接触设计模式,我们有好消息告诉你!首先,多亏了Cocoa的构建方式,你已经使用了许多的设计模式以及被鼓励的最佳实践. ...
- 1.0 iOS中的事件
本文并非最终版本,如有更新或更正会第一时间置顶,联系方式详见文末 如果觉得本文内容过长,请前往本人 “简书” 在用户使用app过程中,会产生各种各样的事件,iOS中的事件可以分为3大类型: UIK ...
- iOS:iOS中的多控制器管理
iOS中的控制器有三种创建方式: 1.通过storyboard创建 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@" ...
- Cordoval在iOS中的运用整理
一:关于Cordoval理论知识 1:PhoneGap是手机平台上流行的一款中间件.它构建在各种手机平台所提供的WebView(浏览器内核)组件的基础之上,使用javascript语言对应用开发者提供 ...
- iOS中的触摸事件和手势处理
iOS中的事件可以分为三大类: 1> 触摸事件 2> 加速计事件 3> 远程控制事件 响应者对象 在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并 ...
随机推荐
- Android实现在线更新的过程案例
一.更新软件的准备 在线更新软件的话需要我们有签名的应用,我们需要把签过名之后的软件放入到服务器中,我的如下: 其中apk是有签名的更新版本! updateinfo.html代码如下: {" ...
- Html-文档类型(DTD)和DOCTYPE
在正式介绍文档类型(DTD)和DOCTYPE之前,我们需要先了解HTML和XHTML的之间的区别,现在Html5已经慢慢的成为主流,之前的数十年一直都是Html4.01的天下,Html4.01于199 ...
- Create an Android library
官方文档 创建 Android 库 [Create an Android library] Android 库在结构上与 Android app module 相同.它可以提供构建应用所需的一切内容, ...
- Vim 命令、操作、快捷键全集
Vim是一个类似于Vi的著名的功能强大.高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性.Vim是自由软件. 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择 ...
- Linux杀毒软件ClamAV初次体验
1:官网 http://www.clamav.net 2:Ubuntu下安装ClamAV sudo apt-get update--更新系统 sudo apt-get install clamav-- ...
- ASP入门(六)-Response对象
Response对象可以从服务器向用户发送输出的结果. Response几种常用方法 方法 描述 BinaryWrite 向浏览器输出二进制的内容 Clear 清除已经缓冲的HTML输出 End 停止 ...
- 【转】Ant之build.xml详解
关键字: ant build.xml Ant的概念 可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令.当编译Linux内核及一些软件的源程序 ...
- SQL与SQL Server
SQL--关系数据库的国际标准语言. SQL Server--著名的数据库管理系统.其他著名的数据库管理系统还有Oracle.Sybase等,它们都实现了SQL语言. 在SQL中,完成所有核心功能 ...
- Max SPA
Stingray Response_ContentType Stingray javascript 其实是支持返回原生html的, 有了这个事情就简单了 RHTML - Response_Conten ...
- mysql标准写法及其他常见问题
/* Navicat MySQL Data Transfer Source Server : localhost_3306 Source Server Version : 50549 Source H ...