• 同时也得比较好的一个封装类


    //

    //  该类管理设备的图标

    #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

  • 相关阅读:
    mac下安装apache tomcat
    前端常用框架和js插件 UI组件等
    HBase二级索引的设计
    通过BulkLoad的方式快速导入海量数据
    Phoenix二级索引(Secondary Indexing)的使用
    java并发编程--Executor框架
    Spark常用函数讲解之Action操作
    Java并发编程--Volatile详解
    Spark常用函数讲解之键值RDD转换
    图解堆排序
  • 原文地址:https://www.cnblogs.com/alihaiseyao/p/3603930.html
Copyright © 2020-2023  润新知