forked from enormego/UIKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIScrollView.m
102 lines (78 loc) · 2.14 KB
/
UIScrollView.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
92
93
94
95
96
97
98
99
100
101
102
//
// UIScrollView.m
// UIKit
//
// Created by Shaun Harrison on 4/30/09.
// Copyright 2009 enormego. All rights reserved.
//
#import "UIScrollView.h"
#import "UIClipView.h"
#import "UIColor.h"
#import <QuartzCore/QuartzCore.h>
@interface UIScrollView (Private)
@property(nonatomic,retain) UIView* documentView;
@end
@implementation UIScrollView
@synthesize backgroundColor=_backgroundColor;
- (void)setupScrollViewDefaults {
self.layer = [CALayer layer];
self.contentView = [[[UIClipView alloc] initWithFrame:self.bounds] autorelease];
self.contentView.wantsLayer = YES;
self.hasVerticalScroller = YES;
self.hasHorizontalScroller = YES;
self.autohidesScrollers = YES;
self.documentView = [[[UIView alloc] initWithFrame:self.bounds] autorelease];
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
- (id)initWithFrame:(NSRect)frameRect {
if((self = [super initWithFrame:frameRect])) {
[self setupScrollViewDefaults];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
if((self = [super initWithCoder:aDecoder])) {
[self setupScrollViewDefaults];
}
return self;
}
- (void)setDocumentSize:(NSSize)aSize {
NSRect aRect = self.documentView.frame;
aRect.size = aSize;
self.documentView.frame = aRect;
}
- (NSSize)documentSize {
return self.documentView.frame.size;
}
- (void)setDocumentOffset:(NSPoint)aPoint {
}
- (NSPoint)documentOffset {
return NSMakePoint(0.0f, 0.0f);
}
- (void)addSubview:(UIView*)aView {
if([aView isKindOfClass:[NSClipView class]]) {
[super addSubview:aView];
} else if([aView isKindOfClass:[NSScroller class]]) {
[super addSubview:aView];
} else {
[self.documentView addSubview:aView];
}
}
- (BOOL)isFlipped {
return YES;
}
- (void)setBackgroundColor:(UIColor *)aColor {
[_backgroundColor release];
_backgroundColor = [aColor retain];
self.documentView.backgroundColor = aColor;
self.contentView.backgroundColor = aColor.NSColor;
[super setBackgroundColor:aColor.NSColor];
}
- (void)superSetBackgroundColor:(NSColor*)aColor {
[super setBackgroundColor:aColor];
}
- (void)dealloc {
[_backgroundColor release];
[super dealloc];
}
@end