-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUIKitAdditions.mm
54 lines (41 loc) · 1.42 KB
/
UIKitAdditions.mm
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
//
// UIKitAdditions.m
// XTide
//
// Created by Lee Ann Rucker on 7/2/16.
// Copyright © 2016 Lee Ann Rucker. All rights reserved.
//
#import "UIKitAdditions.h"
#import "XTColorUtils.h"
#import "XTGraph.h"
#import "XTTideEventsOrganizer.h"
@implementation XTStationRef (iOSAdditions)
- (UIImage *)stationDot
{
CGRect rect = CGRectMake(0, 0, 20, 20);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 2);
rect = CGRectInset(rect, 2, 2);
CGContextRef context = UIGraphicsGetCurrentContext();
UIColor *color = nil;
if (self.isCurrent) {
color = ColorForKey(XTide_ColorKeys[currentdotcolor]);
} else {
color = ColorForKey(XTide_ColorKeys[tidedotcolor]);
}
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillEllipseInRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
@end
@implementation XTStation (iOSAdditions)
- (NSAttributedString *)stationInfo
{
return [[NSAttributedString alloc] initWithData:[[self stationInfoAsHTML] dataUsingEncoding:NSUTF8StringEncoding]
options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
documentAttributes:nil
error:nil];
}
@end