1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- //
- // SPSBWarningtipsView.m
- // 我的社保
- //
- // Created by shanp on 2021/5/31.
- //
- #import "SPSBWarningtipsView.h"
- #import "SPSBUIGeneralHeader.h"
- @implementation SPSBWarningtipsView
- - (instancetype)initWithTitles:(NSArray *)titles {
- self = [super init];
- if (!self) return nil;
- self.backgroundColor = spsb_FDF8EC_color();
- self.clipsToBounds = true;
- [self setTitles:titles];
- return self;
- }
- - (void)setTitles:(NSArray *)titles {
- for (UIView *view in self.subviews) {
- [view removeFromSuperview];
- }
- UIView *tempView = nil;
- for (NSString *title in titles) {
- NSString *str = [title stringByReplacingOccurrencesOfString:@"\r" withString:@""];
- if ([str isEqualToString:@""]) {
- str = @" ";
- }
- UIView *titleView = [UIView new];
- titleView.backgroundColor = spsb_FDF8EC_color();
- [self addSubview:titleView];
- [titleView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.and.trailing.equalTo(0);
- if (tempView) {
- make.top.equalTo(tempView.bottom);
- } else {
- make.top.equalTo(13);
- }
- }];
-
- UIImageView *imageView = [[UIImageView alloc] initWithImage:jxh_getImage(w_info)];
- [titleView addSubview:imageView];
- [imageView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(15);
- make.top.equalTo(8);
- }];
-
-
- UILabel *label = [UILabel convenienceWithFont:spsb_font(12) textColor:spsb_FF801A_color() limitWidth:jxh_screenWidth() - 30 - 15];
- [label setAttributedStringWithText:str lineSpacing:3];
- [titleView addSubview:label];
- [label makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(30);
- make.trailing.equalTo(-15);
- make.top.equalTo(2);
- make.bottom.equalTo(-2);
- }];
- tempView = titleView;
- }
- if (tempView) {
- [tempView makeConstraints:^(JXHConstraintMaker *make) {
- make.bottom.equalTo(-13);
- }];
- }
- }
- @end
|