-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSSMessageTableViewCell.m
74 lines (51 loc) · 1.78 KB
/
SSMessageTableViewCell.m
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// SSMessageTableViewCell.m
// Messages
//
// Created by Sam Soffes on 3/10/10.
// Copyright 2010-2011 Sam Soffes. All rights reserved.
//
#import "SSMessageTableViewCell.h"
#import "SSMessageTableViewCellBubbleView.h"
@implementation SSMessageTableViewCell
#pragma mark NSObject
- (void)dealloc {
[_bubbleView release];
[super dealloc];
}
#pragma mark UITableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.textLabel.hidden = YES;
_bubbleView = [[SSMessageTableViewCellBubbleView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.contentView.frame.size.width, self.contentView.frame.size.height)];
_bubbleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.contentView addSubview:_bubbleView];
[self.contentView sendSubviewToBack:_bubbleView];
}
return self;
}
#pragma mark Getters
- (SSMessageStyle)messageStyle {
return _bubbleView.messageStyle;
}
- (NSString *)messageText {
return _bubbleView.messageText;
}
#pragma mark Setters
- (void)setMessageStyle:(SSMessageStyle)aMessageStyle {
_bubbleView.messageStyle = aMessageStyle;
[_bubbleView setNeedsDisplay];
}
- (void)setMessageText:(NSString *)text {
_bubbleView.messageText = text;
[_bubbleView setNeedsDisplay];
}
- (void)setBackgroundImage:(UIImage *)backgroundImage forMessageStyle:(SSMessageStyle)messsageStyle {
if (messsageStyle == SSMessageStyleLeft) {
_bubbleView.leftBackgroundImage = backgroundImage;
} else if (messsageStyle == SSMessageStyleRight) {
_bubbleView.rightBackgroundImage = backgroundImage;
}
}
@end