12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // RQSimulationResultsHeaderView.m
- // SDJK
- //
- // Created by 张嵘 on 2021/8/10.
- //
- #import "RQSimulationResultsHeaderView.h"
- #define PI 3.14159265358979323846
- @interface RQSimulationResultsHeaderView ()
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UIButton *backBtn;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleLabelHeight;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleLabelToTopConst;
- @property (weak, nonatomic) IBOutlet UIImageView *headerImageView;
- @property (weak, nonatomic) IBOutlet UILabel *nicknameLabel;
- @property (weak, nonatomic) IBOutlet UIView *myContentView;
- @end
- @implementation RQSimulationResultsHeaderView
- + (instancetype)simulationResultsHeaderView {
- return [super rq_viewFromXib];
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
-
-
- CGFloat radius = RQ_SCREEN_WIDTH;
-
- //特别注意:贝塞尔曲线的radius必须为self高度的四分之一,CAShapeLayer的线宽必须为self高度的二分之一
- UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(RQ_SCREEN_WIDTH / 2.f, RQSimulationResultsHeaderViewHeight - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT - radius) radius:radius / 2 startAngle:-PI/2 endAngle:PI *3 / 2 clockwise:YES];
-
- CAShapeLayer *maskLayer = [CAShapeLayer layer];
- maskLayer.path = path.CGPath;
- maskLayer.fillColor = [UIColor clearColor].CGColor;
- maskLayer.strokeColor = RQ_MAIN_BACKGROUNDCOLOR.CGColor;
- maskLayer.lineWidth = radius;
- //等于半径的2倍,以圆的边缘为中心,向圆内部伸展一个半径,向外伸展一个半径,所以看上去以为圆的半径是self高度的一半。
-
- _bgView.layer.mask = maskLayer;
-
- [self bringSubviewToFront:_backBtn];
-
- // [self.layer addSublayer:[UIColor setGradualChangingColor:self fromColor:@"#498EF5" toColor:@"#4DA8E6"]];
-
- _bgView.backgroundColor = [UIColor rq_colorGradientChangeWithSize:CGSizeMake(self.bounds.size.width, self.bounds.size.height - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT) direction:RQGradientChangeDirectionVertical startColor:[UIColor colorWithHexString:@"#498EF5"] endColor:[UIColor colorWithHexString:@"#4DA8E6"]];
-
- _titleLabelHeight.constant = RQ_APPLICATION_NAV_BAR_HEIGHT;
- _titleLabelToTopConst.constant = RQ_APPLICATION_STATUS_BAR_HEIGHT;
-
- _nicknameLabel.text = RQ_USER_MANAGER.nickName;
- [_headerImageView yy_setImageWithURL:[NSURL URLWithString:RQ_USER_MANAGER.headImage] placeholder:RQWebAvatarImagePlaceholder() options:RQWebImageOptionAutomatic completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
- if(image) {
- image = [image scaledToSize:CGSizeMake(54, 54)];
- image = [image qmui_imageWithClippedCornerRadius:27];
- _headerImageView.image = image;
- }
- }];
-
- _myContentView.layer.shadowColor = [UIColor colorWithHexString:@"#7C8188" alpha:0.2f].CGColor;
- [self bringSubviewToFront:_myContentView];
-
- [[RQ_HTTP_Service getScoreInfoAll] subscribeNext:^(RQGetScoreInfoAllModel *scoreInfoAllModel) {
- _examAverageScoreLabel.text = [NSString stringWithFormat:@"%ld", scoreInfoAllModel.avgScore];
- _examAchievementPredictionLabel.text = [NSString stringWithFormat:@"%ld", scoreInfoAllModel.forecastScore];
- _examBestResultsLabel.text = [NSString stringWithFormat:@"%ld", scoreInfoAllModel.maxScore];
- }];
- }
- - (IBAction)backBtnAction:(id)sender {
- [RQ_APPDELEGATE.services popViewModelAnimated:YES];
- }
- - (IBAction)ContinueExamBtnAction:(id)sender {
- [RQ_APPDELEGATE.services popViewModelAnimated:YES];
- }
- @end
|