SPSBWarningtipsView.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // SPSBWarningtipsView.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/5/31.
  6. //
  7. #import "SPSBWarningtipsView.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. @implementation SPSBWarningtipsView
  10. - (instancetype)initWithTitles:(NSArray *)titles {
  11. self = [super init];
  12. if (!self) return nil;
  13. self.backgroundColor = spsb_FDF8EC_color();
  14. self.clipsToBounds = true;
  15. [self setTitles:titles];
  16. return self;
  17. }
  18. - (void)setTitles:(NSArray *)titles {
  19. for (UIView *view in self.subviews) {
  20. [view removeFromSuperview];
  21. }
  22. UIView *tempView = nil;
  23. for (NSString *title in titles) {
  24. NSString *str = [title stringByReplacingOccurrencesOfString:@"\r" withString:@""];
  25. if ([str isEqualToString:@""]) {
  26. str = @" ";
  27. }
  28. UIView *titleView = [UIView new];
  29. titleView.backgroundColor = spsb_FDF8EC_color();
  30. [self addSubview:titleView];
  31. [titleView makeConstraints:^(JXHConstraintMaker *make) {
  32. make.leading.and.trailing.equalTo(0);
  33. if (tempView) {
  34. make.top.equalTo(tempView.bottom);
  35. } else {
  36. make.top.equalTo(13);
  37. }
  38. }];
  39. UIImageView *imageView = [[UIImageView alloc] initWithImage:jxh_getImage(w_info)];
  40. [titleView addSubview:imageView];
  41. [imageView makeConstraints:^(JXHConstraintMaker *make) {
  42. make.leading.equalTo(15);
  43. make.top.equalTo(8);
  44. }];
  45. UILabel *label = [UILabel convenienceWithFont:spsb_font(12) textColor:spsb_FF801A_color() limitWidth:jxh_screenWidth() - 30 - 15];
  46. [label setAttributedStringWithText:str lineSpacing:3];
  47. [titleView addSubview:label];
  48. [label makeConstraints:^(JXHConstraintMaker *make) {
  49. make.leading.equalTo(30);
  50. make.trailing.equalTo(-15);
  51. make.top.equalTo(2);
  52. make.bottom.equalTo(-2);
  53. }];
  54. tempView = titleView;
  55. }
  56. if (tempView) {
  57. [tempView makeConstraints:^(JXHConstraintMaker *make) {
  58. make.bottom.equalTo(-13);
  59. }];
  60. }
  61. }
  62. @end