-
Notifications
You must be signed in to change notification settings - Fork 0
/
JTSImageInfo.m
67 lines (52 loc) · 1.62 KB
/
JTSImageInfo.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
//
// JTSImageInfo.m
//
//
// Created by Jared Sinclair on 3/2/14.
// Copyright (c) 2014 Nice Boy LLC. All rights reserved.
//
#import "JTSImageInfo.h"
@implementation JTSImageInfo
- (NSString *)displayableTitleAltTextSummary {
NSString *text = nil;
if (self.title.length) {
text = [NSString stringWithFormat:@"%@", self.title];
}
else if (self.altText.length) {
text = [NSString stringWithFormat:@"%@", self.altText];
}
return text;
}
- (NSString *)combinedTitleAndAltText {
NSMutableString *text = [[NSMutableString alloc] init];
if (self.title.length) {
[text appendFormat:@"“%@”", self.title];
}
if (self.altText.length) {
if ([self.altText isEqualToString:self.title] == NO) {
[text appendFormat:@"\n\n— — —\n\n%@", self.altText];
}
}
return text;
}
- (NSMutableDictionary *)userInfo {
if (_userInfo == nil) {
_userInfo = [[NSMutableDictionary alloc] init];
}
return _userInfo;
}
- (NSString *)description {
return [NSString stringWithFormat:@"\
%@ %p \n\
imageURL: %@ \n\
referenceRect: (%g, %g) (%g, %g)",
NSStringFromClass(self.class), self,
self.imageURL,
self.referenceRect.origin.x, self.referenceRect.origin.y, self.referenceRect.size.width, self.referenceRect.size.height
];
}
- (CGPoint)referenceRectCenter {
return CGPointMake(self.referenceRect.origin.x + self.referenceRect.size.width/2.0f,
self.referenceRect.origin.y + self.referenceRect.size.height/2.0f);
}
@end