forked from xhan/PlutoLand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPLProgressBar.m
62 lines (45 loc) · 1.12 KB
/
PLProgressBar.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
//
// PLProgressBar.m
// Apollo
//
// Created by xhan on 10-10-8.
// Copyright 2010 ixHan.com. All rights reserved.
//
#import "PLProgressBar.h"
#import "UIViewAdditions.h"
#import "PLCore.h"
@implementation PLProgressBar
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
// Initialization code
_backgroundView = [[UIImageView alloc] initWithFrame:self.bounds];
_frontView = [[UIImageView alloc] initWithFrame:CGRectZero];
_frontView.height = self.height;
_frontView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:_backgroundView];
[self addSubview:_frontView];
self.progress = 0;
}
return self;
}
- (void)dealloc {
PLSafeRelease(_frontView);
PLSafeRelease(_backgroundView);
[super dealloc];
}
- (void)setProgress:(CGFloat)value{
_frontView.width = self.width * value;
_progress = value;
}
- (CGFloat)progress{
return _progress;
}
- (void)setFrontImage:(UIImage *)image
{
_frontView.image = [image stretchableImageWithLeftCapWidth:5 topCapHeight:0];
}
- (void)setBackgroundImage:(UIImage *)image
{
_backgroundView.image = image;
}
@end