不知道怎么描述,就是列表里有百分比的条,单个出现时要有个动画
创建FLGProgressView 继承UIView
FLGProgressView.h
@interface FLGProgressView : UIView
@property (nonatomic, strong) UIView *frontView;///
@property (nonatomic, strong) UIView *backView;
- (void)setpro:(CGFloat)pro;
@end
FLGProgressView.m
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self createView];
}
return self;
}
- (void)createView{
[self addSubview:self.backView];
self.backView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
///
[self addSubview:self.frontView];
self.frontView.frame = CGRectMake(0, 0, 0, self.frame.size.height);
}
- (UIView *)frontView{
if (!_frontView) {
_frontView = [[UIView alloc] init];
_frontView.backgroundColor = [UIColor orangeColor];
}
return _frontView;
}
- (UIView *)backView{
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [UIColor lightGrayColor];
}
return _backView;
}
- (void)setpro:(CGFloat)pro{
self.frontView.frame = CGRectMake(0, 0, 0, self.frame.size.height);
[UIView animateWithDuration:1 animations:^{
self.frontView.frame = CGRectMake(0, 0, self.frame.size.width*pro, self.frame.size.height);
}];
}
controller.m tableviewcell 协议方法里
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *reuse = @"reuse";
TablehaViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
if (!cell) {
cell = [[TablehaViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
}
if (indexPath.row%2==0) {
[cell reloadCell:0.4];
}else{
[cell reloadCell:0.8];
}
return cell;
}
TablehaViewCell.m
创建progress
self.progress = [[FLGProgressView alloc] initWithFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width-20, 10)];
[self.contentView addSubview:self.progress];
给progress 赋值 Pro是个0-1的小数
- (void)reloadCell:(CGFloat)pro{
[self.progress setpro:pro];
}