Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 358 lines (270 sloc) 10.171 kb
3a79356 @soffes Added HUD
soffes authored
1 //
47ffa05 @soffes HUD view orientation improvements. Still not great, but better.
soffes authored
2 // SSHUDView.m
f3d43b6 @soffes The Great Rename
soffes authored
3 // SSToolkit
3a79356 @soffes Added HUD
soffes authored
4 //
5 // Created by Sam Soffes on 9/29/09.
e8c3ce3 @soffes Updated comments and renamed SSDrawingMacros to SSDrawingUtilities
soffes authored
6 // Copyright 2009-2011 Sam Soffes. All rights reserved.
3a79356 @soffes Added HUD
soffes authored
7 //
8
f3d43b6 @soffes The Great Rename
soffes authored
9 #import "SSHUDView.h"
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
10 #import "SSHUDWindow.h"
e8c3ce3 @soffes Updated comments and renamed SSDrawingMacros to SSDrawingUtilities
soffes authored
11 #import "SSDrawingUtilities.h"
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
12 #import "UIView+SSToolkitAdditions.h"
528d116 @soffes Add default images to SSHUDView
soffes authored
13 #import "NSBundle+SSToolkitAdditions.h"
9fbbae2 @soffes Updated views
soffes authored
14 #import <QuartzCore/QuartzCore.h>
528d116 @soffes Add default images to SSHUDView
soffes authored
15 #import "UIImage+SSToolkitAdditions.h"
3a79356 @soffes Added HUD
soffes authored
16
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
17 static CGFloat kIndicatorSize = 40.0;
a04b86d @soffes TWHUDView rewrite
soffes authored
18
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
19 @interface SSHUDView (PrivateMethods)
20 - (void)_setTransformForCurrentOrientation:(BOOL)animated;
21 - (void)_deviceOrientationChanged:(NSNotification *)notification;
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
22 - (void)_removeWindow;
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
23 @end
24
454e654 @soffes Require Apple LLVM compiler 3.0
soffes authored
25 @implementation SSHUDView {
26 SSHUDWindow *_hudWindow;
27 }
28
3a79356 @soffes Added HUD
soffes authored
29
bf2d0ec @soffes Started overhauling documentation
soffes authored
30 #pragma mark - Accessors
62be25e @soffes Updated coding style and started on extremitiesStyle
soffes authored
31
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
32 @synthesize textLabel = _textLabel;
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
33 @synthesize textLabelHidden = _textLabelHidden;
5b58afc @soffes Add `initWithCoder:` to views to allow for use in Interface Builder. …
soffes authored
34 @synthesize activityIndicator = _activityIndicator;
35 @synthesize hudSize = _hudSize;
36 @synthesize loading = _loading;
37 @synthesize successful = _successful;
38 @synthesize completeImage = _completeImage;
39 @synthesize failImage = _failImage;
62be25e @soffes Updated coding style and started on extremitiesStyle
soffes authored
40
41 - (void)setTextLabelHidden:(BOOL)hidden {
42 _textLabelHidden = hidden;
43 _textLabel.hidden = hidden;
44 [self setNeedsLayout];
45 }
46
47
48 - (void)setLoading:(BOOL)isLoading {
49 _loading = isLoading;
50 _activityIndicator.alpha = _loading ? 1.0 : 0.0;
51 [self setNeedsDisplay];
52 }
53
54
55 - (BOOL)hidesVignette {
56 return _hudWindow.hidesVignette;
57 }
58
59
60 - (void)setHidesVignette:(BOOL)hide {
61 _hudWindow.hidesVignette = hide;
62 }
63
64
bf2d0ec @soffes Started overhauling documentation
soffes authored
65 #pragma mark - NSObject
3a79356 @soffes Added HUD
soffes authored
66
a04b86d @soffes TWHUDView rewrite
soffes authored
67 - (id)init {
528d116 @soffes Add default images to SSHUDView
soffes authored
68 return (self = [self initWithTitle:nil loading:YES]);
a04b86d @soffes TWHUDView rewrite
soffes authored
69 }
70
71
3a79356 @soffes Added HUD
soffes authored
72 - (void)dealloc {
146b4d2 The observer was added with object nil so when removing it must also …
Evan Long authored
73 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
74 [self _removeWindow];
3a79356 @soffes Added HUD
soffes authored
75 }
76
5d44fc3 @soffes Cleaned up TWToolkit.bundle and TWViewController modal
soffes authored
77
bf2d0ec @soffes Started overhauling documentation
soffes authored
78 #pragma mark - UIView
3a79356 @soffes Added HUD
soffes authored
79
80 - (id)initWithFrame:(CGRect)frame {
528d116 @soffes Add default images to SSHUDView
soffes authored
81 return (self = [self initWithTitle:nil loading:YES]);
3a79356 @soffes Added HUD
soffes authored
82 }
83
84
85 - (void)drawRect:(CGRect)rect {
a04b86d @soffes TWHUDView rewrite
soffes authored
86 CGContextRef context = UIGraphicsGetCurrentContext();
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
87
8b407e5 @soffes Improved HUD view
soffes authored
88 // Draw rounded rectangle
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
89 CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 0.5f);
90 CGRect rrect = CGRectMake(0.0f, 0.0f, _hudSize.width, _hudSize.height);
91 SSDrawRoundedRect(context, rrect, 14.0f);
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
92
0a4275b @soffes Cleaned up TWHUDView
soffes authored
93 // Image
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
94 if (_loading == NO) {
5d44fc3 @soffes Cleaned up TWToolkit.bundle and TWViewController modal
soffes authored
95 [[UIColor whiteColor] set];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
96
6ac3c7d @soffes Added the ability to add an image instead of using the dingbats.
soffes authored
97 UIImage *image = _successful ? _completeImage : _failImage;
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
98
6ac3c7d @soffes Added the ability to add an image instead of using the dingbats.
soffes authored
99 if (image) {
100 CGSize imageSize = image.size;
101 CGRect imageRect = CGRectMake(roundf((_hudSize.width - imageSize.width) / 2.0f),
102 roundf((_hudSize.height - imageSize.height) / 2.0f),
103 imageSize.width, imageSize.height);
a4e8acb @alaborie Fixed an issue in SSHUDView (related to SSHUDWindow and facebook SDK).
alaborie authored
104 [image drawInRect:imageRect];
6ac3c7d @soffes Added the ability to add an image instead of using the dingbats.
soffes authored
105 return;
106 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
107
5d44fc3 @soffes Cleaned up TWToolkit.bundle and TWViewController modal
soffes authored
108 NSString *dingbat = _successful ? @"" : @"";
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
109 UIFont *dingbatFont = [UIFont systemFontOfSize:60.0f];
110 CGSize dingbatSize = [dingbat sizeWithFont:dingbatFont];
111 CGRect dingbatRect = CGRectMake(roundf((_hudSize.width - dingbatSize.width) / 2.0f),
112 roundf((_hudSize.height - dingbatSize.height) / 2.0f),
113 dingbatSize.width, dingbatSize.height);
bdb7f74 @jyap808 Fix deprecation warnings in iOS 6.
jyap808 authored
114 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
115 [dingbat drawInRect:dingbatRect withFont:dingbatFont lineBreakMode:NSLineBreakByClipping alignment:NSTextAlignmentCenter];
116 #else
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
117 [dingbat drawInRect:dingbatRect withFont:dingbatFont lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentCenter];
bdb7f74 @jyap808 Fix deprecation warnings in iOS 6.
jyap808 authored
118 #endif
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
119 }
ec45ed2 @soffes Updated HUD
soffes authored
120 }
121
a04b86d @soffes TWHUDView rewrite
soffes authored
122
ec45ed2 @soffes Updated HUD
soffes authored
123 - (void)layoutSubviews {
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
124 _activityIndicator.frame = CGRectMake(roundf((_hudSize.width - kIndicatorSize) / 2.0f),
125 roundf((_hudSize.height - kIndicatorSize) / 2.0f),
126 kIndicatorSize, kIndicatorSize);
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
127
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
128 if (_textLabelHidden) {
129 _textLabel.frame = CGRectZero;
130 } else {
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
131 CGSize textSize = [_textLabel.text sizeWithFont:_textLabel.font constrainedToSize:CGSizeMake(self.bounds.size.width, CGFLOAT_MAX) lineBreakMode:_textLabel.lineBreakMode];
132 _textLabel.frame = CGRectMake(0.0f, roundf(_hudSize.height - textSize.height - 10.0f), _hudSize.width, textSize.height);
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
133 }
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
134 }
135
62be25e @soffes Updated coding style and started on extremitiesStyle
soffes authored
136
bf2d0ec @soffes Started overhauling documentation
soffes authored
137 #pragma mark - HUD
a04b86d @soffes TWHUDView rewrite
soffes authored
138
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
139 - (id)initWithTitle:(NSString *)aTitle {
140 return [self initWithTitle:aTitle loading:YES];
141 }
142
143
144 - (id)initWithTitle:(NSString *)aTitle loading:(BOOL)isLoading {
f643aac @soffes Switched to LLVM 1.6 and enabled additional warnings. Updated code to…
soffes authored
145 if ((self = [super initWithFrame:CGRectZero])) {
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
146 self.backgroundColor = [UIColor clearColor];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
147
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
148 _hudSize = CGSizeMake(172.0f, 172.0f);
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
149
8b407e5 @soffes Improved HUD view
soffes authored
150 // Indicator
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
151 _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
152 _activityIndicator.alpha = 0.0;
153 [_activityIndicator startAnimating];
154 [self addSubview:_activityIndicator];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
155
8b407e5 @soffes Improved HUD view
soffes authored
156 // Text Label
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
157 _textLabel = [[UILabel alloc] initWithFrame:CGRectZero];
158 _textLabel.font = [UIFont boldSystemFontOfSize:14];
159 _textLabel.backgroundColor = [UIColor clearColor];
160 _textLabel.textColor = [UIColor whiteColor];
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
161 _textLabel.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.7f];
fe409e1 @soffes Add more f's
soffes authored
162 _textLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
bdb7f74 @jyap808 Fix deprecation warnings in iOS 6.
jyap808 authored
163 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
164 _textLabel.textAlignment = NSTextAlignmentCenter;
165 _textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
166 #else
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
167 _textLabel.textAlignment = UITextAlignmentCenter;
168 _textLabel.lineBreakMode = UILineBreakModeTailTruncation;
bdb7f74 @jyap808 Fix deprecation warnings in iOS 6.
jyap808 authored
169 #endif
528d116 @soffes Add default images to SSHUDView
soffes authored
170 _textLabel.text = aTitle ? aTitle : SSToolkitLocalizedString(@"Loading...");
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
171 [self addSubview:_textLabel];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
172
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
173 // Loading
174 self.loading = isLoading;
528d116 @soffes Add default images to SSHUDView
soffes authored
175
176 // Images
177 self.completeImage = [UIImage imageNamed:@"hud-check.png" bundleName:kSSToolkitBundleName];
178 self.failImage = [UIImage imageNamed:@"hud-x.png" bundleName:kSSToolkitBundleName];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
179
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
180 // Orientation
181 [self _setTransformForCurrentOrientation:NO];
182 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_deviceOrientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
8b407e5 @soffes Improved HUD view
soffes authored
183 }
184 return self;
185 }
186
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
187
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
188 - (void)show {
c893cb4 @soffes ARC
soffes authored
189 // [self retain];
8f077b6 @soffes Actually remove window when HUD is dismissed
soffes authored
190 if (!_hudWindow) {
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
191 _hudWindow = [SSHUDWindow defaultWindow];
8f077b6 @soffes Actually remove window when HUD is dismissed
soffes authored
192 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
193
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
194 _hudWindow.alpha = 0.0f;
195 self.alpha = 0.0f;
196 [_hudWindow addSubview:self];
197 [_hudWindow makeKeyAndVisible];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
198
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
199 [UIView beginAnimations:@"SSHUDViewFadeInWindow" context:nil];
200 _hudWindow.alpha = 1.0f;
201 [UIView commitAnimations];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
202
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
203 CGSize windowSize = _hudWindow.frame.size;
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
204 CGRect contentFrame = CGRectMake(roundf((windowSize.width - _hudSize.width) / 2.0f),
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
205 roundf((windowSize.height - _hudSize.height) / 2.0f) + 10.0f,
206 _hudSize.width, _hudSize.height);
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
207
208
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
209 CGFloat offset = 20.0f;
210 if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
211 self.frame = CGRectSetY(contentFrame, contentFrame.origin.y + offset);
212 } else {
213 self.frame = CGRectSetX(contentFrame, contentFrame.origin.x + offset);
214 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
215
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
216 [UIView beginAnimations:@"SSHUDViewFadeInContentAlpha" context:nil];
217 [UIView setAnimationDelay:0.1];
218 [UIView setAnimationDuration:0.2];
219 self.alpha = 1.0f;
220 [UIView commitAnimations];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
221
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
222 [UIView beginAnimations:@"SSHUDViewFadeInContentFrame" context:nil];
223 [UIView setAnimationDelay:0.1];
224 [UIView setAnimationDuration:0.3];
225 self.frame = contentFrame;
226 [UIView commitAnimations];
227 }
228
229
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
230 - (void)completeWithTitle:(NSString *)aTitle {
bca88d4 @hramos Add error image, methods to complete HUD with error instead of checkm…
hramos authored
231 self.successful = YES;
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
232 self.loading = NO;
6a23e1d @soffes Cleaned up ivars and removed switch cell
soffes authored
233 _textLabel.text = aTitle;
fbad6a2 @soffes Implemented loading in TWHUDView
soffes authored
234 }
235
236
12851fd @soffes Tweaked TWHUDView size
soffes authored
237 - (void)completeAndDismissWithTitle:(NSString *)aTitle {
238 [self completeWithTitle:aTitle];
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
239 [self performSelector:@selector(dismiss) withObject:nil afterDelay:1.0];
240 }
241
242
243 - (void)completeQuicklyWithTitle:(NSString *)aTitle {
244 [self completeWithTitle:aTitle];
245 [self show];
246 [self performSelector:@selector(dismiss) withObject:nil afterDelay:1.05];
12851fd @soffes Tweaked TWHUDView size
soffes authored
247 }
248
249
cf3512e @hramos Change to failWithTitle: and failAndDismissWithTitle:
hramos authored
250 - (void)failWithTitle:(NSString *)aTitle {
bca88d4 @hramos Add error image, methods to complete HUD with error instead of checkm…
hramos authored
251 self.successful = NO;
252 self.loading = NO;
253 _textLabel.text = aTitle;
254 }
255
256
cf3512e @hramos Change to failWithTitle: and failAndDismissWithTitle:
hramos authored
257 - (void)failAndDismissWithTitle:(NSString *)aTitle {
258 [self failWithTitle:aTitle];
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
259 [self performSelector:@selector(dismiss) withObject:nil afterDelay:1.0];
919cfee @vladg SSHUDView now tries harder to stay alive intil it is truely dismissed
vladg authored
260 }
261
262
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
263 - (void)failQuicklyWithTitle:(NSString *)aTitle {
264 [self failWithTitle:aTitle];
265 [self show];
266 [self performSelector:@selector(dismiss) withObject:nil afterDelay:1.05];
bca88d4 @hramos Add error image, methods to complete HUD with error instead of checkm…
hramos authored
267 }
268
269
a04b86d @soffes TWHUDView rewrite
soffes authored
270 - (void)dismiss {
c893cb4 @soffes ARC
soffes authored
271 // [self autorelease];
a04b86d @soffes TWHUDView rewrite
soffes authored
272 [self dismissAnimated:YES];
273 }
274
275
276 - (void)dismissAnimated:(BOOL)animated {
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
277 [UIView beginAnimations:@"SSHUDViewFadeOutContentFrame" context:nil];
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
278 [UIView setAnimationDuration:0.2];
47ffa05 @soffes HUD view orientation improvements. Still not great, but better.
soffes authored
279 CGRect contentFrame = self.frame;
280 CGFloat offset = 20.0f;
281 if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
282 self.frame = CGRectSetY(contentFrame, contentFrame.origin.y + offset);
283 } else {
284 self.frame = CGRectSetX(contentFrame, contentFrame.origin.x + offset);
285 }
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
286 [UIView commitAnimations];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
287
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
288 [UIView beginAnimations:@"SSHUDViewFadeOutContentAlpha" context:nil];
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
289 [UIView setAnimationDelay:0.1];
290 [UIView setAnimationDuration:0.2];
291 self.alpha = 0.0f;
292 [UIView commitAnimations];
043e29d @evanlong For the case were animated == NO the _hudWindow was not fading away.
evanlong authored
293
294 [UIView beginAnimations:@"SSHUDViewFadeOutWindow" context:nil];
295 _hudWindow.alpha = 0.0f;
296 [UIView commitAnimations];
297
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
298 if (animated) {
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
299 [self performSelector:@selector(_removeWindow) withObject:nil afterDelay:0.3];
5140041 @soffes Actually remove window when dismissing HUD
soffes authored
300 } else {
301 [self _removeWindow];
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
302 }
8d3c955 @soffes Started rewriting SSHUDView (Issue #8)
soffes authored
303 }
304
305
bf2d0ec @soffes Started overhauling documentation
soffes authored
306 #pragma mark - Private Methods
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
307
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
308 - (void)_setTransformForCurrentOrientation:(BOOL)animated {
ffcf0ad @steipete fixes enum conversion warnings
steipete authored
309 UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
310 NSInteger degrees = 0;
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
311
f68616a @soffes Cleaned up HUD view a bit
soffes authored
312 // Landscape left
313 if (orientation == UIInterfaceOrientationLandscapeLeft) {
314 degrees = -90;
315 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
316
f68616a @soffes Cleaned up HUD view a bit
soffes authored
317 // Landscape right
318 if (orientation == UIInterfaceOrientationLandscapeRight) {
319 degrees = 90;
320 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
321
f68616a @soffes Cleaned up HUD view a bit
soffes authored
322 // Portrait upside down
323 else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
324 degrees = 180;
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
325 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
326
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
327 CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
328
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
329 if (animated) {
330 [UIView beginAnimations:@"SSHUDViewRotationTransform" context:nil];
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
331 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
332 [UIView setAnimationDuration:0.3];
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
333 }
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
334
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
335 [self setTransform:rotationTransform];
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
336
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
337 if (animated) {
338 [UIView commitAnimations];
339 }
340 }
341
7d742f8 @soffes Improved HUD orientation change and dismiss animation
soffes authored
342
ab4493b @daikini Add landscape support to SSHUDView.
daikini authored
343 - (void)_deviceOrientationChanged:(NSNotification *)notification {
344 [self _setTransformForCurrentOrientation:YES];
345 [self setNeedsDisplay];
346 }
f68616a @soffes Cleaned up HUD view a bit
soffes authored
347
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
348
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
349 - (void)_removeWindow {
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
350 [_hudWindow resignKeyWindow];
351 _hudWindow = nil;
0b3b493 Modified SSHudView to be capable of showing multiple lines of text
Tim Johnsen authored
352
871dfa1 @soffes Focus the bottom window after the HUD is dismissed. Maybe It should b…
soffes authored
353 // Return focus to the first window
354 [[[[UIApplication sharedApplication] windows] objectAtIndex:0] makeKeyWindow];
ff6b7c0 @soffes Improved SSHUDView. You can now do the following:
soffes authored
355 }
356
3a79356 @soffes Added HUD
soffes authored
357 @end
Something went wrong with that request. Please try again.