RQSimulationResultsHeaderView.m 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // RQSimulationResultsHeaderView.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/10.
  6. //
  7. #import "RQSimulationResultsHeaderView.h"
  8. #define PI 3.14159265358979323846
  9. @interface RQSimulationResultsHeaderView ()
  10. @property (weak, nonatomic) IBOutlet UIView *bgView;
  11. @property (weak, nonatomic) IBOutlet UIButton *backBtn;
  12. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleLabelHeight;
  13. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleLabelToTopConst;
  14. @property (weak, nonatomic) IBOutlet UIImageView *headerImageView;
  15. @property (weak, nonatomic) IBOutlet UILabel *nicknameLabel;
  16. @property (weak, nonatomic) IBOutlet UIView *myContentView;
  17. @end
  18. @implementation RQSimulationResultsHeaderView
  19. + (instancetype)simulationResultsHeaderView {
  20. return [super rq_viewFromXib];
  21. }
  22. - (void)awakeFromNib {
  23. [super awakeFromNib];
  24. CGFloat radius = RQ_SCREEN_WIDTH;
  25. //特别注意:贝塞尔曲线的radius必须为self高度的四分之一,CAShapeLayer的线宽必须为self高度的二分之一
  26. 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];
  27. CAShapeLayer *maskLayer = [CAShapeLayer layer];
  28. maskLayer.path = path.CGPath;
  29. maskLayer.fillColor = [UIColor clearColor].CGColor;
  30. maskLayer.strokeColor = RQ_MAIN_BACKGROUNDCOLOR.CGColor;
  31. maskLayer.lineWidth = radius;
  32. //等于半径的2倍,以圆的边缘为中心,向圆内部伸展一个半径,向外伸展一个半径,所以看上去以为圆的半径是self高度的一半。
  33. _bgView.layer.mask = maskLayer;
  34. [self bringSubviewToFront:_backBtn];
  35. // [self.layer addSublayer:[UIColor setGradualChangingColor:self fromColor:@"#498EF5" toColor:@"#4DA8E6"]];
  36. _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"]];
  37. _titleLabelHeight.constant = RQ_APPLICATION_NAV_BAR_HEIGHT;
  38. _titleLabelToTopConst.constant = RQ_APPLICATION_STATUS_BAR_HEIGHT;
  39. _nicknameLabel.text = RQ_USER_MANAGER.nickName;
  40. [_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) {
  41. if(image) {
  42. image = [image scaledToSize:CGSizeMake(54, 54)];
  43. image = [image qmui_imageWithClippedCornerRadius:27];
  44. _headerImageView.image = image;
  45. }
  46. }];
  47. _myContentView.layer.shadowColor = [UIColor colorWithHexString:@"#7C8188" alpha:0.2f].CGColor;
  48. [self bringSubviewToFront:_myContentView];
  49. [[RQ_HTTP_Service getScoreInfoAll] subscribeNext:^(RQGetScoreInfoAllModel *scoreInfoAllModel) {
  50. _examAverageScoreLabel.text = [NSString stringWithFormat:@"%ld", scoreInfoAllModel.avgScore];
  51. _examAchievementPredictionLabel.text = [NSString stringWithFormat:@"%ld", scoreInfoAllModel.forecastScore];
  52. _examBestResultsLabel.text = [NSString stringWithFormat:@"%ld", scoreInfoAllModel.maxScore];
  53. }];
  54. }
  55. - (IBAction)backBtnAction:(id)sender {
  56. [RQ_APPDELEGATE.services popViewModelAnimated:YES];
  57. }
  58. - (IBAction)ContinueExamBtnAction:(id)sender {
  59. [RQ_APPDELEGATE.services popViewModelAnimated:YES];
  60. }
  61. @end