单军华
2018-07-11 7b02207537d35bfa1714bf8beafc921f717d100a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
//  HMEmoticonButton.m
//  表情键盘
//
//  Created by 刘凡 on 16/3/5.
//  Copyright © 2016年 itcast. All rights reserved.
//
 
#import "HMEmoticonButton.h"
#import "UIImage+HMEmoticon.h"
#import "HMEmoticon.h"
 
@implementation HMEmoticonButton
 
#pragma mark - 属性
- (void)setDeleteButton:(BOOL)deleteButton {
    _deleteButton = deleteButton;
    
    [self setImage:[UIImage hm_imageNamed:@"compose_emotion_delete"]
          forState:UIControlStateNormal];
    [self setImage:[UIImage hm_imageNamed:@"compose_emotion_delete_highlighted"]
          forState:UIControlStateHighlighted];
}
 
- (void)setEmoticon:(HMEmoticon *)emoticon {
    _emoticon = emoticon;
    
    self.hidden = (emoticon == nil);
    
    [self setImage:[UIImage hm_imageNamed:emoticon.imagePath] forState:UIControlStateNormal];
    [self setTitle:emoticon.emoji forState:UIControlStateNormal];
}
 
#pragma mark - 构造函数
+ (instancetype)emoticonButtonWithFrame:(CGRect)frame tag:(NSInteger)tag {
    HMEmoticonButton *button = [[self alloc] initWithFrame:frame];
    
    button.tag = tag;
    
    return button;
}
 
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.titleLabel.font = [UIFont systemFontOfSize:32];
        self.titleEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 0);
    }
    return self;
}
 
@end