zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    更改文件、图片名称思路,我们的名字在以后添加_2等待
    UIStepper使用的具体解释的控制
    ArcSDE10.1配置Oracle 监听器来使用SQL操作ST_Geometry(个人改动版)
    SDE ST_Geometry SQL st_intersects查询很慢的解决方法
    通过SQL直接插入、修改ArcGIS SDE空间表中的数据
    使用POI读写word docx文件
    Weblogic读不到Word文件
    POI写Word换行
    使用POI转换word doc文件
    POI生成Web版Word文件
  • 原文地址:https://www.cnblogs.com/gcb999/p/3229745.html
Copyright © 2011-2022 走看看