Belows是我想要理解的代码:
@interface ViewController () {
UIView *progressBarView;
UIView *progressBgView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Pass the frame where you want to display progress bar
[self addProgressView:CGRectMake(10, 100, self.view.frame.size.width-20, 30)];
// Apply colors
[self setProgressBgColor:[UIColor redColor]];
[self setProgressBarColor:[UIColor greenColor]];
// Pass progress percent value here
[self setPercentage:80];
}
#pragma mark - Progress methods
- (void)addProgressView:(CGRect)progressFrame {
UIView *progressView = [[UIView alloc] initWithFrame:progressFrame];
//Progress background view
progressBgView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, progressView.frame.size.width-10, progressView.frame.size.height-10)];
progressBgView.backgroundColor = [UIColor redColor];
progressBgView.layer.cornerRadius = 4.0;
//Progress animation view
progressBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, progressBgView.frame.size.height)];
progressBarView.backgroundColor = [UIColor greenColor];
progressBarView.layer.cornerRadius = 4.0;
[progressBgView addSubview:progressBarView];
[progressView addSubview:progressBgView];
[self.view addSubview:progressView];
}
- (void)setPercentage:(int)percentage {
[UIView animateWithDuration:1.0 animations:^{
[progressBarView setFrame:CGRectMake(0,0,(progressBgView.frame.size.width*percentage)/100,progressBgView.frame.size.height)];
} completion:^(BOOL finished) {
}];
}
- (void)setProgressBgColor:(UIColor *)color {
progressBgView.backgroundColor = color;
}
- (void)setProgressBarColor:(UIColor *)color {
progressBarView.backgroundColor = color;
}
@end
此#!/bin/bash
cat > pl.gp <<EOF
...
CONTENTS
...
EOF
脚本的结果会生成一个shell
文件,其中包含pl.gp
符合之前的所有文本。有没有人帮我理解shell强大的重定向用法?
答案 0 :(得分:1)
这称为heredoc。
从<<EOF
到以下EOF
令牌的所有内容都会在其stdin上输入cat
进程。 cat
(就其性质而言)将通过stdout重定向(>
运算符)将其转储到指定文件中