-
Notifications
You must be signed in to change notification settings - Fork 3
/
Utils.mm
executable file
·38 lines (33 loc) · 1.06 KB
/
Utils.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
#import "Utils.h"
#import "constants.h"
@implementation Utils
// Create a UIImageView circle with given diameter and color
+(UIImageView *)makeCircle:(int)diameter withColor:(UIColor *)color {
UIGraphicsBeginImageContextWithOptions(
CGSizeMake(
diameter,
diameter
),
NO,
0.0f
);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGRect rect = CGRectMake(0, 0, diameter, diameter);
CGContextSetFillColorWithColor(ctx, color.CGColor);
CGContextFillEllipseInRect(ctx, rect);
CGContextRestoreGState(ctx);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return [[UIImageView alloc] initWithImage:img];
}
// Get the default parameters
+(NSMutableDictionary *)getDefaultPrefs {
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] init];
[prefs setValue:kTypeDefault forKey:kTypeKey];
[prefs setValue:kColorDefault forKey:kColorKey];
[prefs setValue:kRadiusDefault forKey:kRadiusKey];
[prefs setValue:kGroupsDefault forKey:kGroupsKey];
return prefs;
}
@end