-
Notifications
You must be signed in to change notification settings - Fork 16
/
UIView.m
91 lines (69 loc) · 1.54 KB
/
UIView.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// UIView.m
// UIKit
//
// Created by Shaun Harrison on 4/30/09.
// Copyright 2009 enormego. All rights reserved.
//
#import "UIView.h"
#import "UIColor.h"
#import <QuartzCore/QuartzCore.h>
@implementation UIView
@synthesize backgroundColor=_backgroundColor;
- (id)initWithFrame:(NSRect)frame {
if((self = [super initWithFrame:frame])) {
[self setLayer:[CALayer layer]];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
if((self = [super initWithCoder:aDecoder])) {
[self setLayer:[CALayer layer]];
}
return self;
}
- (void)setNeedsDisplay {
[super setNeedsDisplay:YES];
}
- (void)display {
[super display];
}
- (void)displayIfNeeded {
[self layoutIfNeeded];
[super displayIfNeeded];
}
- (void)setBackgroundColor:(UIColor *)aColor {
[_backgroundColor release];
_backgroundColor = [aColor retain];
self.layer.backgroundColor = self.backgroundColor.CGColor;
}
- (void)viewDidMoveToSuperview {
[super viewDidMoveToSuperview];
}
- (void)setNeedsLayout {
_needsLayout = YES;
[self setNeedsDisplay];
[self.layer setNeedsLayout];
}
- (void)layoutSubviews {
}
- (void)layoutIfNeeded {
if(_needsLayout) {
[self layoutSubviews];
_needsLayout = NO;
}
}
- (BOOL)isFlipped {
return YES;
}
- (NSString*)description {
NSString* description = [super description];
description = [description substringToIndex:description.length - 1];
description = [description stringByAppendingFormat:@"; %@>", NSStringFromRect(self.frame)];
return description;
}
- (void)dealloc {
self.backgroundColor = nil;
[super dealloc];
}
@end