31
@implementation ImageWell
34
- (id) initWithFrame: (CGRect) frame
36
if (!(self = [super initWithFrame: frame]))
33
@implementation ElImageView
42
35
- (id) initWithCoder: (NSCoder*) coder
44
37
if (!(self = [super initWithCoder: coder]))
47
instructionsView = [[UITextView alloc] initWithFrame: CGRectInset([self bounds], 0.0f, 0.0f)];
48
[instructionsView setText: @"Tap and hold to paste image, double-tap to select image from gallery."];
49
//[instructionsView setBackgroundColor: [UIColor yellowColor]];
50
[instructionsView setTextColor: [UIColor blackColor]];
51
[instructionsView setBackgroundColor: [UIColor colorWithWhite: 1.0f alpha: 1.0f]];
52
[instructionsView setFont: [UIFont systemFontOfSize: 17.0f]];
53
[instructionsView setEditable: NO];
54
[instructionsView setUserInteractionEnabled: NO];
55
[instructionsView setTextAlignment: UITextAlignmentCenter];
56
[self addSubview: instructionsView];
58
[instructionsView layer].opacity = 0.0f;
40
borderColor = [[UIColor grayColor] retain];
47
[self setBackgroundColor: [UIColor clearColor]];
64
- (void) setFrame: (CGRect) frame
66
[super setFrame: frame];
67
[instructionsView setFrame: CGRectInset([self bounds], 0.0f, 0.0f)];
55
[borderColor release];
70
60
- (void) drawRect: (CGRect) rect
72
62
CGContextRef c = UIGraphicsGetCurrentContext();
102
92
CGRect drawRect = CGRectMake(bounds.origin.x + 0.5f*(bounds.size.width - drawWidth), bounds.origin.y + 0.5f*(bounds.size.height - drawHeight), drawWidth, drawHeight);
105
createPathInRoundedRect(c, drawRect, 5.0f);
97
createPathInRoundedRect(c, drawRect, cornerRadius);
109
[image drawInRect: drawRect];
101
[image drawInRect: drawRect blendMode: kCGBlendModeNormal alpha: imageAlpha];
111
103
CGContextRestoreGState(c);
113
[[UIColor blackColor] set];
114
createPathInRoundedRect(c, drawRect, 5.0f);
115
CGContextStrokePath(c);
106
[[borderColor colorWithAlphaComponent: imageAlpha] set];
107
createPathInRoundedRect(c, drawRect, cornerRadius);
108
CGContextSetLineWidth(c, borderWidth);
109
CGContextStrokePath(c);
113
- (void) setImageAlpha: (float) a
116
[self setNeedsDisplay];
119
@synthesize image, cornerRadius, borderColor, borderWidth, fillView, imageAlpha;
125
@implementation ImageWell
128
- (id) initWithFrame: (CGRect) frame
130
if (!(self = [super initWithFrame: frame]))
136
- (id) initWithCoder: (NSCoder*) coder
138
if (!(self = [super initWithCoder: coder]))
141
instructionsView = [[UITextView alloc] initWithFrame: CGRectInset([self bounds], 0.0f, 0.0f)];
142
[instructionsView setText: @"Tap and hold to paste image,\nOR\nDouble-tap to select image from gallery."];
143
//[instructionsView setBackgroundColor: [UIColor yellowColor]];
144
[instructionsView setTextColor: [UIColor whiteColor]];
145
[instructionsView setBackgroundColor: [UIColor clearColor]];
146
[instructionsView setFont: [UIFont systemFontOfSize: 24.0f]];
147
[instructionsView setEditable: NO];
148
[instructionsView setUserInteractionEnabled: NO];
149
[instructionsView setTextAlignment: UITextAlignmentCenter];
150
[self addSubview: instructionsView];
152
[instructionsView layer].opacity = 0.0f;
158
- (void) setFrame: (CGRect) frame
160
[super setFrame: frame];
161
[instructionsView setFrame: CGRectInset([self bounds], 0.0f, 0.0f)];
148
189
if ([touch tapCount] == 1)
150
ElFloatAnimation* anim = [[[ElFloatAnimation alloc] init] autorelease];
191
ElFloatAnimation* anim = nil;
193
anim = [[[ElFloatAnimation alloc] init] autorelease];
152
195
[anim setStartValue: [[instructionsView layer] opacity]];
153
[anim setEndValue: 0.5f];
196
[anim setEndValue: 0.667f];
154
197
[anim setDuration: 0.5f];
155
[anim setStartTime: [ElAnimation now]];
156
198
[anim setTarget: [instructionsView layer]];
157
199
[anim setProperty: @"opacity"];
158
[anim queueWithKey: nil];
160
anim = [[[ElFloatAnimation alloc] init] autorelease];
162
[anim setStartValue: 0.5f];
200
[anim queueForKey: @"text-opacity" atBeginning: YES cancelPending: YES];
203
anim = [[[ElFloatAnimation alloc] init] autorelease];
205
[anim setStartValue: imageAlpha];
206
[anim setEndValue: 0.333f];
207
[anim setDuration: 0.5f];
208
[anim setTarget: self];
209
[anim setProperty: @"imageAlpha"];
210
[anim queueForKey: @"image-opacity" atBeginning: YES cancelPending: YES];
212
[[ElAnimation delayedAnimationWithDelay: 2.5f] queueForKey: @"text-opacity" atBeginning: NO cancelPending: NO];
213
[[ElAnimation delayedAnimationWithDelay: 2.5f] queueForKey: @"image-opacity" atBeginning: NO cancelPending: NO];
215
anim = [[[ElFloatAnimation alloc] init] autorelease];
217
[anim setStartValue: 0.667f];
163
218
[anim setEndValue: 0.0f];
164
219
[anim setDuration: 0.5f];
165
[anim setStartTime: [ElAnimation now] + 3.0f];
166
220
[anim setTarget: [instructionsView layer]];
167
221
[anim setProperty: @"opacity"];
168
[anim queueWithKey: nil];
222
[anim queueForKey: @"text-opacity" atBeginning: NO cancelPending: NO];
225
anim = [[[ElFloatAnimation alloc] init] autorelease];
227
[anim setStartValue: 0.333f];
228
[anim setEndValue: 1.0f];
229
[anim setDuration: 0.5f];
230
[anim setTarget: self];
231
[anim setProperty: @"imageAlpha"];
232
[anim queueForKey: @"image-opacity" atBeginning: NO cancelPending: NO];