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的对象才能接收并 ...
随机推荐
- [leetcode]Search in Rotated Sorted Array II @ Python
原题地址:https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/ 题意: Follow up for "Sea ...
- 如何查看Isilon节点的硬件信息?
Isilon节点虽然是一个Linux,但是很多linux下常用的命令都没有,比如说看内存的.笔者经过试验,列出了一些可用的命令. 查看硬件状态 isi_hw_status 查看内存 sysctl hw ...
- javascript——获取列表选择行的列值
表格布局 方法 代码 $("#send").click(function(){ //获取选择的行号 n= $('input:radio[name="radio" ...
- List 集合的交集
private void Test() { List<string> lsA = new List<string>(); lsA.Add("A"); lsA ...
- 为Subline Text 3 添加支持ini文件语法高亮
转: http://lancelot.blog.51cto.com/393579/1783653 在Subline text 官网下载了Subline text 3 .不过发现没有对ini格式文件的语 ...
- 无脑抢标——算了吧
第一版时,我对拍拍贷是恐惧的,缓解我的恐惧的方法,就是寻找尽可能安全的方案.然后,我就发现了这个策略:超过信用等级普通利率的标的.A标一般16,B一般18--那我就寻找大于16的A,大于18的B,C我 ...
- Flask传递中文URL时的问题
在非IE浏览器上都很好,几乎不用处理,但IE不行,学习了半天,有以下要点: 1.Meta如果设置了编码,如UTF8,浏览器都将中文转码发送,但IE不会! <meta http-equiv=&qu ...
- 如何检查显卡类型,DirectX和OpenGL的版本
How To: Check the graphics card type and OpenGL version From: http://support.esri.com/technical-arti ...
- (算法)Travel Information Center
题目: Aps Island has many cities. In the summer, many travellers will come to the island and attend fe ...
- 从 bootup.js 学习加载脚本等资源
本文内容 如何使用 示例 参考资料 本文的目的在于,通过 bootup.js 的源代码,认识如何从客户端加载服务器的文件,特别是 JavaScript 文件,注入到页面,并存储在本地缓存,以扩展对 J ...