IOS--表情粗显示

//
//  EmotionView.m
//  WXWeibo
//
//  Created by apple on 14-6-3.
//  Copyright (c) 2014年 com.tyust. All rights reserved.
//

#import "EmotionView.h"

#define item_weidth 42
#define item_height 45

@implementation EmotionView
{
    NSMutableArray *pages;

}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self _init];
        self.backgroundColor = [UIColor clearColor];
    
    }
    return self;
}


-(void)_init
{
    
    NSString *emotionPlistPath = [[NSBundle mainBundle]pathForResource:@"emoticons" ofType:@"plist"];
    
    NSArray *array = [[NSArray alloc]initWithContentsOfFile:emotionPlistPath];
    
    
    int pageCout = array.count/28;
    
    
    pages = [[NSMutableArray alloc]initWithCapacity:pageCout];
    
    
    NSMutableArray *emotions = nil;
    
    for(int i = 0;i<array.count;i++)
    {
    
        if(i%28==0)
        {
            emotions = [[NSMutableArray alloc]initWithCapacity:28];
            
            [pages addObject:emotions];
        }
        [emotions addObject:array[i]];


    }
    
    
    NSLog(@"pageCout--> %d",pageCout);
    
    self.width = (pageCout+1) * 320;
    self.height =  4 * item_height;
}

-(void)drawRect:(CGRect)rect
{
    int colum = 0,row=0;

    
    for(int i=0;i<pages.count;i++)
    {
        NSMutableArray *emotions = pages[i];
        
        
        for(int j = 0;j<emotions.count;j++)
        {
            colum++;
            
            NSDictionary *dic = emotions[j];
            
            
            NSString *imgName = [dic objectForKey:@"png"];
            
            UIImage *img = [UIImage imageNamed:imgName];
            
            CGRect rect =  CGRectMake(colum * item_weidth + i * 320 - 20 ,row * item_height + 15,30,30);
            
            [img drawInRect:rect];
            
            
            if(colum%7==0)
            {
                row++;
                colum=0;
            }
            
            if(row%4==0)
            {
                
                row=0;
            }
        }
    }
}

@end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值