博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ios 中UIViewController的分类
阅读量:5978 次
发布时间:2019-06-20

本文共 2738 字,大约阅读时间需要 9 分钟。

#import 
#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(0, 0, self.view.bounds.size.width, 44)]; tpNavView.tag = TOPVIEWTAG; [self.view addSubview:tpNavView]; [tpNavView release]; UIImageView *navImageView = [UIImageView ImageViewImageName:@"top_navigation_image.png" frame:tpNavView.bounds]; navImageView.tag = 10010; [tpNavView addSubview:navImageView]; UILabel *label = [UILabel LabWithFrame:tpNavView.bounds text:self.title textColor:[UIColor whiteColor] textAlign:NSTextAlignmentCenter font:[UIFont boldSystemFontOfSize:22]]; [tpNavView addSubview:label]; label.tag=10020; UIButton *back = [UIButton ButtonWithImageName:@"btn_back_image.png" hImageName:@"btn_back_image.png" frame:CGRectMake(5, 6, 45, 32) 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(0, 0, self.view.bounds.size.width, 44); UIImageView *image = ASDynamicCast(UIImageView, [topView viewWithTag:10010]); image.frame = topView.bounds; UILabel *tLab = ASDynamicCast(UILabel, [topView viewWithTag:10020]); tLab.frame = topView.bounds; UIButton *back = ASDynamicCast(UIButton, [topView viewWithTag:0x404]); back.frame = CGRectMake(5, 6, 45, 32);}-(void)backButtonAction:(id)sender{ [self.navigationController popViewControllerAnimated:YES];}-(CGRect)CGRectMake{ CGRect topViewRec,bottonViewRec; CGRectDivide(self.view.bounds, &topViewRec, &bottonViewRec, 44, CGRectMinYEdge); return bottonViewRec;}-(void)showMessage:(NSString*)message{ if ([message length] > 0) { UIAlertView *av = [[UIAlertView alloc] initWithTitle:nil message:message delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [av show]; [av release]; }}@end

 

转载于:https://www.cnblogs.com/gcb999/p/3229745.html

你可能感兴趣的文章
ASP.NET Core 2 学习笔记(三)中间件
查看>>
hbase region split源码分析
查看>>
MySQL备份之分库分表备份脚本
查看>>
Java 与 Netty 实现高性能高并发
查看>>
SurfControl人工智能新突破 领跑反垃圾邮件
查看>>
一个动态ACL的案例
查看>>
openstack 之 windows server 2008镜像制作
查看>>
VI快捷键攻略
查看>>
Win server 2012 R2 文件服务器--(三)配额限制
查看>>
卓越质量管理成就创新高地 中关村软件园再出发
查看>>
linux rsync 远程同步
查看>>
httpd的manual列目录漏洞
查看>>
myeclipse2014破解过程
查看>>
漫谈几种反编译对抗技术
查看>>
Timer 和 TimerTask 例子
查看>>
Spring BOOT 集成 RabbitMq 实战操作(一)
查看>>
安装python3.5注意事项及相关命令
查看>>
进程通信之无名信号量
查看>>
并发串行调用接口
查看>>
CMD 修改Host文件 BAT
查看>>