• 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(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
  • 相关阅读:
    生产排程系统设计(二)设计思路
    一个ExtJs项目的Demo
    信息流与生产作业的同步与监控
    生产企业的IT人才储备困局
    生产排程系统设计(三)设计概要
    生产排程系统设计(一)设计愿景
    找工作时,你如何看待薪资问题
    sql 跨服务器 select ,update,insert
    Biztalk和Widows Wrokflow Fundation的区别和联系
    BizTalk 2010 虚拟环境分布式安装需要注意的问题
  • 原文地址:https://www.cnblogs.com/gcb999/p/3229745.html
Copyright © 2020-2023  润新知