-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathORColourView.m
More file actions
48 lines (36 loc) · 970 Bytes
/
ORColourView.m
File metadata and controls
48 lines (36 loc) · 970 Bytes
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
//
// ARColourView.m
// AutolayoutExample
//
// Created by Orta on 27/06/2013.
// Copyright (c) 2013 Orta. All rights reserved.
//
#import "ORColourView.h"
@implementation UIColor (DebugColours)
+ (UIColor *)debugColourRandom {
uint32_t index = arc4random_uniform(360);
return [UIColor colorWithHue:index/360.0 saturation:0.398 brightness:0.773 alpha:1.000];
}
@end
@implementation ORColourView
- (instancetype)init
{
self = [super init];
if (!self) return nil;
self.backgroundColor = [UIColor debugColourRandom];
self.textAlignment = NSTextAlignmentCenter;
self.numberOfLines = 0;
self.userInteractionEnabled = YES;
return self;
}
- (CGSize)intrinsicContentSize {
if (!CGSizeEqualToSize(self.fakeContentSize, CGSizeZero)) {
return self.fakeContentSize;
}
return [super intrinsicContentSize];
}
- (NSString *)description
{
return [@"ORColourView : " stringByAppendingString: self.text];
}
@end