-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadingView.m
69 lines (57 loc) · 2.04 KB
/
LoadingView.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
//
// LoadingView.m
// AvocadoTest1
//
// Created by Jake on 12-02-29.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "LoadingView.h"
@implementation LoadingView
@synthesize progressLabel;
@synthesize indicatorView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
splashImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"splashScreen.jpg"]];
indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicatorView startAnimating];
progressLabel = [[UILabel alloc] init];
[progressLabel setBackgroundColor:[UIColor clearColor]];
[progressLabel setTextAlignment:UITextAlignmentCenter];
[progressLabel setAdjustsFontSizeToFitWidth:YES];
[progressLabel setTextColor:[UIColor blackColor]];
[progressLabel setText:@"Initializing..."];
[self addSubview:splashImage];
[self addSubview:indicatorView];
[self addSubview:progressLabel];
}
return self;
}
-(void)layoutSubviews
{
int labelWidth = 200;
int labelDistanceFromIndicator = 10;
int indicatorWidth = 37;
double heightCoeficient = 0.8;
double widthCoeficient = 0.5;
[splashImage setFrame:[self frame]];
[indicatorView setFrame:CGRectMake(
([self frame].size.width * widthCoeficient) - (indicatorWidth / 2),
([self frame].size.height * heightCoeficient) - (indicatorWidth / 2),
indicatorWidth,
indicatorWidth)];
[progressLabel setFrame:CGRectMake(
[indicatorView frame].origin.x + (indicatorWidth / 2) - (labelWidth / 2),
[indicatorView frame].origin.y + indicatorWidth + labelDistanceFromIndicator,
labelWidth,
21)];
}
-(void)setAlpha:(CGFloat)alpha
{
[super setAlpha:alpha];
[splashImage setAlpha:alpha];
[indicatorView setAlpha:alpha];
[progressLabel setAlpha:alpha];
}
@end