zoukankan      html  css  js  c++  java
  • 同时也得比较好的一个封装类

    //

    //  该类管理设备的图标

    #import <Foundation/Foundation.h>

    typedefenum {

        diandeng=0,

    //    chazuoSel,

        

        chazuo,

    //    diandengSel,

        

        dianshi,

    //    dianshiSel,

        

        dianfanbao,

    //    dianfanbaoSel,

        

        gongfang,

    //    gongfangSel,

        

        fenshan,

    //    fenshanSel,

        

        kongtiao,

    //    kongtiaoSel,

    }ButtonCenterIco;

    @interface ImageDataManage : NSObject

    +(ImageDataManage *)instance;

    //通过设备类型返回相应的图标

    -(NSString *)getButtonCenterIco:(ButtonCenterIco)icoType isHighlight:(BOOL)isHighlight;

    -(NSMutableDictionary *)imageDic;

    @end

    //

    //  ImageDataManage.m

    //  SmartHomeWIFI

    //

    //  Created by 深圳市 秀软科技有限公司 on 14-1-24.

    //  Copyright (c) 2014 huhuaxiang. All rights reserved.

    //

    #import "ImageDataManage.h"

    static ImageDataManage *imageDataManage=nil;

    @implementation ImageDataManage

    -(id)init

    {

        if(self=[superinit])

        {

            

        }

        returnself;

    }

    +(ImageDataManage *)instance

    {

        if(!imageDataManage)

        {

            imageDataManage=[[ImageDataManagealloc]init];

        }

        returnimageDataManage;

    }

    -(NSString *)getButtonCenterIco:(ButtonCenterIco)icoType isHighlight:(BOOL)isHighlight

    {

        NSString *imageName=[[self imageDic] objectForKey:[NSNumber numberWithInt:icoType]];

        NSRange range=[imageName rangeOfString:@"."options:NSBackwardsSearch];

        if(isHighlight)//高亮状态_sel

        {

            NSString *s=[imageName substringWithRange:NSMakeRange(0, range.location)];

            NSString *e=[imageName substringWithRange:NSMakeRange(range.location+1, imageName.length-(range.location+1))];

            imageName=[NSString stringWithFormat:@"%@_sel.%@",s,e];

        }

        return imageName;

    }

    -(NSMutableDictionary *)imageDic

    {

        

        NSMutableDictionary *dic=[[NSMutableDictionaryalloc]initWithCapacity:5];

         [dic setObject:@"buttonCenterIco_diandeng.png"forKey:[NSNumbernumberWithInt:diandeng]];  //1

    //    [dic setObject:@"buttonCenterIco_chazuo_sel.png" forKey:[NSNumber numberWithInt:chazuoSel]];

        

         [dic setObject:@"buttonCenterIco_chazuo.png"forKey:[NSNumbernumberWithInt:chazuo]];     //2

    //    [dic setObject:@"buttonCenterIco_diandeng_sel.png" forKey:[NSNumber numberWithInt:diandengSel]];

        

        [dic setObject:@"buttonCenterIco_dianshi.png"forKey:[NSNumbernumberWithInt:dianshi]];    //3

    //    [dic setObject:@"buttonCenterIco_dianshi_sel.png" forKey:[NSNumber numberWithInt:dianshiSel]];

        

        [dic setObject:@"buttonCenterIco_dianfanbao.png"forKey:[NSNumbernumberWithInt:dianfanbao]];    //4

    //    [dic setObject:@"buttonCenterIco_dianfanbao_sel.png" forKey:[NSNumber numberWithInt:dianfanbaoSel]];

        

        [dic setObject:@"buttonCenterIco_gongfang.png"forKey:[NSNumbernumberWithInt:gongfang]];     //5

    //    [dic setObject:@"buttonCenterIco_gongfang_sel.png" forKey:[NSNumber numberWithInt:gongfangSel]];

        

        [dic setObject:@"buttonCenterIco_fenshan.png"forKey:[NSNumbernumberWithInt:fenshan]];    //6

    //    [dic setObject:@"buttonCenterIco_fenshan_sel.png" forKey:[NSNumber numberWithInt:fenshanSel]];

        

        [dic setObject:@"buttonCenterIco_kongtiao.png"forKey:[NSNumbernumberWithInt:kongtiao]];    //7

    //    [dic setObject:@"buttonCenterIco_kongtiao_sel.png" forKey:[NSNumber numberWithInt:kongtiaoSel]];

        

        return dic;

    }

    @end

  • 相关阅读:
    c/c++字符串传递
    从一个小程序明白new和delete的奇特现象
    Linux下构造函数string需要注意的问题
    字符串转time_t
    CentOS7基础建站指南(笔记)
    图与搜索
    面向的对象编程的小猫腻
    多线程编程
    生产者消费者模式-Java实现
    Java-代理模式的理解
  • 原文地址:https://www.cnblogs.com/alihaiseyao/p/3603930.html
Copyright © 2011-2022 走看看