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的对象才能接收并 ...
随机推荐
- go语言之进阶篇主协程先退出
1.主协程先退出 示例: package main import ( "fmt" "time" ) //主协程退出了,其它子协程也要跟着退出 func main ...
- EntityFramework6 快速入门教程【转】
https://www.cnblogs.com/wujingtao/p/5401113.html 不得不说EF在国内实在是太小众,相关的技术文章真实屈指可数,而且很多文章都很旧了,里面使用的版本跟如今 ...
- [leetcode]Pow(x, n) @ Python
原题地址:https://oj.leetcode.com/problems/powx-n/ 题意:Implement pow(x, n). 解题思路:求幂函数的实现.使用递归,类似于二分的思路,解法来 ...
- caffe添加python数据层
caffe添加python数据层(ImageData) 在caffe中添加自定义层时,必须要实现这四个函数,在C++中是(LayerSetUp,Reshape,Forward_cpu,Backward ...
- Eclipse添加tomcat服务器以及解决404的问题
Eclipse JavaEE IDE添加tomcat服务器 1. 先做准备工作,首先下载工具 点击下方链接下载 1) Tomcat v7.0 2) Eclipse IDE for Ja ...
- Ios之网络编程NSURLConnection
通过NSURLConnection主要通过四个类进行网络访问:NSURL,NSURLRequest,NSMutableURLRequest,NSURLConnection 一.基本知识 (1)NSUR ...
- 设置让php能够以root权限来执行exec() 或者 shell_exec()
一.查看启动你php的进程的用户是谁. 可以通过在命令行执行:ps -ef | grep php来看.或者在php中执行 echo exec('whoami') 来查看.centos下默认会是nobo ...
- Android 设计原则【转载+整理】
原文地址 本文内容 吸引我的眼球 简化我的生活 让我眼前一亮 在使用过大量 Android APP 后,你会发现,遵循了下面这些原则的 APP 将会有更好的用户体验. 我们知道,往往国企的那些软件,都 ...
- Discuz常见小问题-如何安装模板,使用模板
点击应用,获取更多插件 在模板页面中选择需要的类型(需要注册一个账号) 找好一个模板之后,点击安装应用(一般也会有演示) 安装完成之后可以在界面-风格管理中选择安装好的模板,选中新的模板,点击提交即可 ...
- loadscript加载
function load_script(xyUrl, callback){ var head = document.getElementsByTagName('head')[0]; var scri ...